1

Given a text file (.txt) containing comma seperated values such as 6,3,2,6,3,7,6,4,... I want to read the integer values to a pandas data frame with the method .read_csv.

import pandas as pd

data_frame = pd.read_csv(csv_config['path'], sep=",")

The resulting values are stored in data_frame.columns and look like this: 6, 3, 2, 6.1, 3.1, 7, 6.2, 4, ...

Where do the float values come from, when I expected Integer values?

1 Answer 1

2

Pandas assign a unique name to each column. So the first occurence of 6 has a column name "6", the second has "6.1" etc. Note that they are strings rather than floats.

If you want to read the first row as values (instead of column headers), you should do:

df = pd.read_csv(csv, header=None)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.