【问题标题】:How to set index while have only one column in big data using pandas?如何在使用熊猫的大数据中只有一列的情况下设置索引?
【发布时间】:2019-10-26 11:15:35
【问题描述】:

我只想将 India 设置为索引并想删除第一列。我该怎么做,如果有人知道,请告诉我。

【问题讨论】:

  • 你可以在这里改进你的代码,过去的图像不好。

标签: python-3.x pandas jupyter-notebook jupyter


【解决方案1】:

您的数据集中只有一列?否则你必须在阅读 csv 时这样做。 如果我明白你想要什么。 试试这个。

rd = pd.read_csv('world_population.csv', index_col="india")
rd.reset_index(inplace=True)

【讨论】:

    【解决方案2】:

    您可以使用set_index 设置索引并使用drop=True 删除现有索引。

    所以,像

    a.set_index('India', inplace=True, drop=True)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-02-22
      • 2018-02-04
      • 2021-07-21
      • 1970-01-01
      • 2021-10-10
      • 2017-05-03
      • 1970-01-01
      • 2021-10-02
      相关资源
      最近更新 更多