-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpandabear04.py
35 lines (26 loc) · 985 Bytes
/
pandabear04.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/python3
import pandas as pd
def main():
# create a dataframe ciscocsv
ciscocsv = pd.read_csv("ciscodata.csv")
# create a dataframe ciscojson
ciscojson = pd.read_json("ciscodata2.json")
# The line below concats and reapplies the index value
ciscodf = pd.concat([ciscocsv, ciscojson], ignore_index=True, sort=False)
## export to json
## do not include index number
ciscodf.to_json("combined_ciscodata.json", orient="records")
## export to csv
## do not include index number
ciscodf.to_csv("combined_ciscodata.csv", index=False)
## export to Excel
## do not include index number to xls
ciscodf.to_excel("combined_ciscodata.xls", index=False)
## do not include index number to xlsx
ciscodf.to_excel("combined_ciscodata.xlsx", index=False)
## create a python dictionary
## do not include index number
x = ciscodf.to_dict(orient='records')
print(x)
if __name__ == "__main__":
main()