I have to do a Machine Learning project and my data set is in the form of JSON files. I have a feature position with 3 values (x,y,z). When I convert the JSON files to CSV files with Python I have the values of feature position in the form of array.
How can I generate from one feature three features pos_x, pos_y and pos_z ??
JSON: "pos":[3838.387671754935,5853.151423739182,1.895]
CSV: "pos": "[3838.387671754935,5853.151423739182,1.895]"
But I must have 3 separated features pos_x : 3838.387671754935, pos_y: 5853.151423739182, pos_z: 1.895
The code I used :
import pandas as pd
import json
data = []
with open('JSONfile.json') as fh:
for line in fh:
data.append(json.loads(line))
df = pd.DataFrame.from_dict(data)
df.to_csv ('csvFile.csv', index = False)