1

How can I split this dataframe in two separate columns?

enter image description here

I have tried:

df_partes1=pd.DataFrame(df_partes1[1].values.tolist(), index=df_partes1[0], columns=['x','y'])

but:

Shape of passed values is (12, 1), indices imply (12, 2)
1
  • Post the output of df.to_dict() in your question Commented Oct 10, 2021 at 8:20

1 Answer 1

1

You can use:

df = pd.DataFrame(data={0: ['Neck', 'RShoulder', 'LShoulder', 'RElbow', 'RWrist', 'LElbow'],
                        1: [None, None, (840, 183), None, None, (936,255)]})

df[['new_col_1', 'new_col_2']] = df[1].apply(pd.Series)

Output:

           0           1  new_col_1  new_col_2
0       Neck        None        NaN        NaN
1  RShoulder        None        NaN        NaN
2  LShoulder  (840, 183)      840.0      183.0
3     RElbow        None        NaN        NaN
4     RWrist        None        NaN        NaN
5     LElbow  (936, 255)      936.0      255.0
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.