Give column name when read csv file pandas

前端 未结 4 1411
你的背包
你的背包 2021-01-30 19:39

This is the example of my dataset.

>>> user1 = pd.read_csv(\'dataset/1.csv\')
>>> print(user1)
          0  0.69464   3.1735   7.5048
0  0.0306         


        
4条回答
  •  灰色年华
    2021-01-30 20:09

    user1  = pd.read_csv('dataset/1.csv',  names=['Time',  'X',  'Y',  'Z']) 
    

    names parameter in read_csv function is used to define column names. If you pass extra name in this list, it will add another new column with that name with NaN values.

    header=None is used to trim column names is already exists in CSV file.

提交回复
热议问题