How to set in pandas the first column and row as index?

前端 未结 3 1267
伪装坚强ぢ
伪装坚强ぢ 2021-02-02 06:17

When I read in a CSV, I can say pd.read_csv(\'my.csv\', index_col=3) and it sets the third column as index.

How can I do the same if I have a pandas datafra

3条回答
  •  北荒
    北荒 (楼主)
    2021-02-02 07:01

    You can try this regardless of the number of rows

    df = pd.read_csv('data.csv', index_col=0)
    

提交回复
热议问题