且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

获取 Pandas DataFrame 的行索引值作为列表?

更新时间:2022-11-14 09:06:22

获取index值作为list/list的Index/MultiIndex 的代码>元组s 做:

To get the index values as a list/list of tuples for Index/MultiIndex do:

df.index.values.tolist()  # an ndarray method, you probably shouldn't depend on this

list(df.index.values)  # this will always work in pandas