I have a database column that's been converted to a Pandas dataframe and it looks like below . My actual data has much more columns and rows with different key: value
pair.
df["Records"]
{"ID":"1","ID_1":"40309","type":"type1"}
{"ID":"2","ID_1":"40310","type":"type1"}
{"ID":"3","ID_1":"40311","type":"type1"}
I want to split this into multiple columns in a dataframe.
df1:
ID ID_1 type
1 40309 type1
2 40310 type1
3 40311 type1
I tried this code
json_Str=df.to_dict()
json_dump= json.dumps(json_Str)
json_dump=json_dump.replace("\\", "")
with open("H:\\df2.json", 'w') as fp:
# json.dump(result, fp, indent=4)
print(json_dump, file=fp)
output file has dictionary key value pair
Output:
{"Records":"{"ID":"1","ID_1":"40309","type":"type1"}
{"ID":"2","ID_1":"40310","type":"type1"}
{"ID":"3","ID_1":"40311","type":"type1"}"}
How do I convert a json column to csv format in pandas?