【问题标题】:How to retrieve all indexes from pandas DataFrame如何从 pandas DataFrame 中检索所有索引
【发布时间】:2013-04-20 17:05:47
【问题描述】:

如何从 pandas 0.10.1 DataFrame 中检索所有索引?

我尝试在文档和网络上查找,但至少半小时后仍然没有任何结果。

谢谢, 斯拉瓦

【问题讨论】:

标签: python indexing pandas


【解决方案1】:

正如 Jeff 所说,您可以在 official docs 中找到此信息。示例:

>>> df = DataFrame(np.random.rand(3,2), index = list('abc'), columns=list('df'))
>>> df
     d           f
a    0.629197    0.921025
b    0.534993    0.018760
c    0.156801    0.298251

索引:

>>> df.index
Index([a, b, c], dtype=object)

列:

>>> df.columns
Index([d, f], dtype=object)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-08-22
    • 2019-04-13
    • 2018-02-28
    • 2018-06-18
    • 1970-01-01
    • 1970-01-01
    • 2017-01-07
    • 2020-06-22
    相关资源
    最近更新 更多