3 回答

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

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

TA貢獻1852條經驗 獲得超7個贊
幫助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.
默認情況下,該系列將轉換為具有新索引的數據幀。但是使用 時drop=False,會返回帶有重置索引的系列。這對我來說似乎是倒退的 - 默認重置系列索引將是“reset_index”恕我直言的更自然的結果。
添加回答
舉報