3 回答

TA貢獻(xiàn)1866條經(jīng)驗(yàn) 獲得超5個(gè)贊
您正在使用Series.reset_index
。所以要檢查的正確頁面是:
https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.reset_index.html

TA貢獻(xiàn)1770條經(jīng)驗(yàn) 獲得超3個(gè)贊
根據(jù)Series Docs
:
Series 是一個(gè)一維標(biāo)記數(shù)組,能夠保存任何類型的數(shù)據(jù)。
當(dāng)您執(zhí)行 a 時(shí)reset_index()
,會(huì)向其中添加另一列,因此它不再是one-dimensional
Series,而是變成了dataframe
。
從reset_index docs
:
生成一個(gè)新的 DataFrame 或 Series 并重置索引。
希望這能消除你的疑慮。

TA貢獻(xiàn)1852條經(jīng)驗(yàn) 獲得超7個(gè)贊
幫助Series.reset_index是
reset_index(self, level=None, drop=False, name=None, inplace=False)
? ? Generate a new DataFrame or Series with the index reset.
? ??
? ? This is useful when the index needs to be treated as a column, or
? ? when the index is meaningless and needs to be reset to the default
? ? before another operation.
? ? ...
文檔drop是
? ? drop : bool, default False
? ? ? ? Just reset the index, without inserting it as a column in
? ? ? ? the new DataFrame.
默認(rèn)情況下,該系列將轉(zhuǎn)換為具有新索引的數(shù)據(jù)幀。但是使用 時(shí)drop=False,會(huì)返回帶有重置索引的系列。這對(duì)我來說似乎是倒退的 - 默認(rèn)重置系列索引將是“reset_index”恕我直言的更自然的結(jié)果。
添加回答
舉報(bào)