2

using the following code:

import pandas as pd

with open('data/training_Origional.csv', 'r') as f:

data2 = pd.read_csv(f)
#Col_Names = list(data2.columns.values)

# data2 = pd.DataFrame(data2.row.str.split('\t', 1).tolist(), columns=Col_Names)

print(data2)

# print(Col_Names)

I would like to read in a CSV file and then preform operations on the column values. When I run this code as is I get this kind of output:

0   100000\t138.47\t51.655\t97.827\t27.98\t0.9\t1...
1   100001\t160.937\t68.768\t103.235\t48.146\t-999...
2   100002\t-999\t162.172\t125.953\t35.635\t-999\t...
3   100003\t143.905\t81.417\t80.943\t0.414\t-999\t...

I would like to separate out the one column into many columns using the "\t" as a delimiter, but when I uncomment the commented lines of code, my code doesn't work. Is there a simpler way of "splitting" a column in a pandas dataframe?

1 Answer 1

1

You need to specify the separator for your "csv":

pd.read_csv('data/training_Origional.csv', sep='\t')
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.