Ada Stra
Ada Stra

Reputation: 1581

Pandas won't load first of the columns in a CSV file

I started working through the book Doing Data Science and I'm doing the first exercise in Python. They provide data here: data for book

I do this:

ny = pd.DataFrame.from_csv('/path/nyt1.csv', sep=',')

I get 4 columns, the first is missing and there should be 5! If I open the file in LibreOffice, I get 5 columns.

I tried changing parameters a bit, but can't figure out what's going on.

Data looks like this:

"Age","Gender","Impressions","Clicks","Signed_In"
36,0,3,0,1
73,1,3,0,1
30,0,3,0,1

Upvotes: 0

Views: 120

Answers (2)

Ada Stra
Ada Stra

Reputation: 1581

@Plug4 solved the issue, if I import with pd.read_csv('/path/filename.csv') it works.

Upvotes: 1

Alexander
Alexander

Reputation: 109546

Just use read_csv:

ny = pd.read_csv('nyt.csv')
>>> ny.head()
   Age  Gender  Impressions  Clicks  Signed_In
0   36       0            3       0          1
1   73       1            3       0          1
2   30       0            3       0          1
3   49       1            3       0          1
4   47       1           11       0          1

Upvotes: 1

Related Questions