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

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

如何處理這種情況:“ n / a”在熊貓數(shù)據(jù)框中顯示為“ nan”,但無法對(duì)其進(jìn)行字符串匹配和替換

如何處理這種情況:“ n / a”在熊貓數(shù)據(jù)框中顯示為“ nan”,但無法對(duì)其進(jìn)行字符串匹配和替換

ibeautiful 2021-04-08 14:15:59
我有一個(gè)CSV文件,其中幾行n/a。當(dāng)我將其加載為pandas數(shù)據(jù)框時(shí),顯示為nan。當(dāng)我使用類似功能這會(huì)導(dǎo)致問題split,lower等這些幾行。data_df['column'][104]>>> nandata_df['column'][104].split()>>> AttributeError                            Traceback (most recent call last)<ipython-input-38-6efe06f0a4ec> in <module>()----> 1 data_df['column'][104].split()AttributeError: 'float' object has no attribute 'split'data_df['column'][104].lower()>>>AttributeError                            Traceback (most recent call last)<ipython-input-41-c80cc9ae0712> in <module>()----> 1 data_df['column'][104].lower()AttributeError: 'float' object has no attribute 'lower'當(dāng)我嘗試nan用空格替換s(不會(huì)導(dǎo)致這些錯(cuò)誤)時(shí),使用該fillna方法不會(huì)執(zhí)行任何操作:data_df.fillna('')data_df['column'][104]>>> nan所以我嘗試將其替換為字符串:for i in range(len(data_df)):    if data_df['column'][i]=='nan':        data_df['column'][i]=''data_df['column'][104]>>> nanfor i in range(len(data_df)):    if data_df['column'][i]=='n/a':        data_df['column'][i]=''data_df['column'][104]>>> nan以下內(nèi)容不打印任何內(nèi)容:for i in range(len(data_df)):    if (data_df['column'][i]=='nan' or data_df['column'][i]=='n/a'):        print(data_df['column'][i])為什么我無法捕捉和替換nans或n/as?以及我該如何解決?
查看完整描述

2 回答

?
嚕嚕噠

TA貢獻(xiàn)1784條經(jīng)驗(yàn) 獲得超7個(gè)贊

data_df.fillna('')創(chuàng)建數(shù)據(jù)框的副本。如果要更改原始數(shù)據(jù)框,請(qǐng)致電data_df.fillna('', inplace=True)


查看完整回答
反對(duì) 回復(fù) 2021-04-27
  • 2 回答
  • 0 關(guān)注
  • 186 瀏覽
慕課專欄
更多

添加回答

舉報(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)