pandas read_csv and filter columns with usecols

后端 未结 5 1355
小鲜肉
小鲜肉 2020-11-28 03:00

I have a csv file which isn\'t coming in correctly with pandas.read_csv when I filter the columns with usecols and use multiple indexes.

5条回答
  •  再見小時候
    2020-11-28 03:23

    You have to just add the index_col=False parameter

    df1 = pd.read_csv('foo.csv',
         header=0,
         index_col=False,
         names=["dummy", "date", "loc", "x"], 
         index_col=["date", "loc"], 
         usecols=["dummy", "date", "loc", "x"],
         parse_dates=["date"])
      print df1
    

提交回复
热议问题