I have code which produces a CSV by printing as shown below
array_all = {'Hand': [alldata], 'Pose':[keypoints], 'Face Pose': [face_position]}
df = pd.DataFrame(
array_all
)
df.to_csv('test.csv',
mode='w',
index=False,
header=True)
To give context to how these objects are created, here's the code for one of the objects, all objects are using the same structure
face_position = []
for data_point in results.face_landmarks.landmark:
if 0.6 <= data_point.x < 0.8:
face_position.append('Straight')
else:
face_position.append('Angled')
print(face_position)
Here the face_landmarks refers to objects created from the mediapipe library(
However, I want it to look like this
CodePudding user response:
In this line of code:
array_all = {'Hand': [alldata], 'Pose':[keypoints], 'Face Pose': [face_position]}
You are creating nested lists in each of your columns. Do not forget that alldata
, keypoints
and face_position
are already lists.
Instead of the above, do the following:
array_all = {'Hand': alldata, 'Pose':keypoints, 'Face Pose': face_position}