【发布时间】:2020-07-22 03:30:07
【问题描述】:
this is my original dataframe, I want to use the Day column as the index of the dataframe
passing the 'Day' column into set_index()
为什么新索引中有多余的括号和逗号?
【问题讨论】:
-
不确定
j2010是什么,但请查看其中的Day列。由于Day列出现在df数据框中,请将df = j2010.set_index('Day')行改为df.set_index('Day', inplace=True)。 -
@MDR
j2010是 DataFrame 的变量名。然后在设置索引时将其重新分配给df。 -
通过 print(df.dtypes) 来检查 Day 的类型?
标签: python pandas indexing comma parentheses