我的 csv 格式原始資料如下
text,location,user_follower_count,user_verified
shameful a poor man from bihar is killed j amp k administration under central rule did not even arrange for his body to be flown,NA,NA,NA
being right about anything can be its own reward but you migh more for aquarius,NA,NA,NA
they don t want herd immunity they want a herd mentality,NA,NA,NA
我正在嘗試按如下方式讀取上述檔案。
raw_data = pd.read_csv(raw_tweet_data,sep=",", header='infer')
但是所有內容都被洗掉了列(文本)下。location,user_follower_count,user_verified 列是“Nan”。我嘗試了“分隔符”和“sep”。兩者都不起作用。為什么會這樣?

uj5u.com熱心網友回復:
一旦我通過提及已解決的列名而遇到此類問題,請在閱讀時嘗試提及列以及其他引數,例如 pd.read_csv(columns=[...])。
uj5u.com熱心網友回復:
問題是因為位置、user_follower_count 和 user_verified 等列中的“NA”字串將“NA”字串讀取為 Nan。一旦我將字串“NA”更改為“不可用”,問題就解決了。有點棘手。謝謝。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/313631.html
上一篇:在CSV檔案中添加和附加資料
下一篇:將嵌套的CSV資料轉換為json
