第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

為什么 pd.reset_index 將 Series 轉(zhuǎn)換為 DataFrame

為什么 pd.reset_index 將 Series 轉(zhuǎn)換為 DataFrame

慕工程0101907 2023-12-26 15:10:03
我有以下數(shù)據(jù):接下來我執(zhí)行:讓我困惑的是reset_index()將Series更改為DataFrame。這是為什么?看到pandas文檔后,我預(yù)計(jì)會(huì)出現(xiàn)錯(cuò)誤,因?yàn)閞eset_index僅適用于DataFrame:預(yù)先感謝您為我解決了這個(gè)問題。
查看完整描述

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


查看完整回答
反對(duì) 回復(fù) 2023-12-26
?
德瑪西亞99

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-dimensionalSeries,而是變成了dataframe

reset_index docs

生成一個(gè)新的 DataFrame 或 Series 并重置索引。

希望這能消除你的疑慮。


查看完整回答
反對(duì) 回復(fù) 2023-12-26
?
慕姐4208626

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é)果。


查看完整回答
反對(duì) 回復(fù) 2023-12-26
  • 3 回答
  • 0 關(guān)注
  • 203 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)