简体   繁体   中英

Read CSV file in Pandas Python

I'm trying to read CSV file.

import pandas as pd
df = pd.read_csv(r'C:\Users\San\TEMP OLSTP MECH AMT.csv')
df.head()

But when I show the dataset, it looks messed up. 在此处输入图片说明

contd. 在此处输入图片说明

How to fix it? Is there any set up needed?

Your data is ; -sheared, you need to inform pandas about that, try

import pandas as pd
df = pd.read_csv(r'C:\Users\San\TEMP OLSTP MECH AMT.csv',sep=";")
df.head()

Read pandas.read_csv docs if you want to know more

Try this

  import pandas as pd
 df = pd.read_csv(r'C:\Users\San\TEMP OLSTP MECH 
           AMT.csv', sep=';' ) 
  df.head()

 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM