0

I have an excel column as shown below :-

FileName               Coordinates
abc.text               0 0.41, 0.42, 0.43, 0.44

I want the output to be in this fashion :-

FileName               Coordinates                   Label    X-1      Y-1      X-3      X-4
abc.txt                0, 0.41, 0.42, 0.43, 0.44       0      0.41     0.42     0.43     0.44

I have written the below code and before it worked for me, dont know what I am mission in this specific case :-

import pandas as pd


df = pd.read_csv('path/to/Coordinates_v3_updated.csv')

df[['Label', 'x1','y1', 'x2', 'y2']] = df['Coordinates'].str.split(" ",expand=True)

print(df)

df.to_csv('path/to/save/to/Coordinates_v3_updated_v1.csv', index=False)
print("Done")

1 Answer 1

1

replace df[['Label', 'x1','y1', 'x2', 'y2']] = df['Coordinates'].str.split(" ",expand=True)

with df[['Label', 'x1','y1', 'x2', 'y2']] = df['Coordinates'].str.split(", ",expand=True)

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.