当前,一个具有10 file行的.csv文件被卡住。我将数据集加载到一个名为rawdata的数据帧Python中。该文件具有ascii代码,可能是因为其输出的错误'utf-8‘编解码器无法解码位置21中的字节0x99 :无效的启动字节,解决方案在任何地方都没有正确提到。在这里输入代码
进口numpy作为np进口熊猫作为pd进口用作sci
导入sys重载(Sys) sys.setdefaultencoding("ISO-8859-1")
导入os打印os.getcwd()
os.chdir('D:\DJ\Placement reports\')
setwd()
rawdata=pd.read_csv('D:\DJ\Placement Reports \ Placement Reports_ Apr_Mar_May Page 2.csv',newline='',Copy=‘utf-8’)
rawdata=pd.read_csv("D:\DJ\Placement Reports \ Placement Reports_ Apr_Mar_May Page 1.csv")
rawdata=pd.read_csv("D:\DJ\Pyhton analysis\wagering.csv")
a.encode('utf-8').strip()
X= pd.read_csv("D:\DJ\Placement reports\Test1.csv")
打开(‘D:\DJ\ Placement Reports \Placement Reports_ Apr_Mar_May Page 2.csv',newline='',Copy=’utf-8‘)
数据框架::月安置URL类型广告广告组点击Impr。CTR Avg。中国共产党花费4月18日移动应用程序:审评委信息(Dream11,Myteam11提示和IPL新闻) (Google ),由BRAJ & GEETA公司https://play.google.com/store/apps/details?id=manager.attendance.fantasycrickettips移动应用程序显示-亲和-关键字-主题Display_Keywords 52,584 61,340 0.86%?1.76 ? 92,484.03移动应用程序: NewsDog -最新新闻,打破新闻,地方新闻(谷歌播放),由NewsDog Team https://play.google.com/store/apps/details?id=com.newsdog移动应用程序显示-亲和-关键词-主题-主题-意图28,106 43,14,179,0.65%?2.85 ? 79,991.28移动应用程序:审评委信息(Dream11,Myteam11提示和IPL新闻)(谷歌播放),由BRAJ & GEETA公司https://play.google.com/store/apps/details?id=manager.attendance.fantasycrickettips移动应用程序显示-自定义-意图-意图28,106 43,14,179 0.65%?2.85?79,991.28移动应用程序:审评委Intent(Dream11,Myteam11提示和IPL新闻)(谷歌播放),由BRAJ & GEETA公司https://play.google.com/store/apps/details?id=manager.attendance.fantasycrickettips移动应用程序显示-亲和-关键字-主题Audience_Affinity 39,526 39,727 1.00%?1.79 ? 70,662.24 -18 us.com http://us.com站点显示-亲和-关键字-主题Audience_Affinity 23,792 60,06,433 0.40%?2.83 ? 67,301.35 3月-18移动应用程序: GiftMoney (谷歌游戏),由KingToUpper https://play.google.com/store/apps/details?id=com.akp151998.giftmoney移动应用程序显示-亲和-关键字-主题Audience_Affinity 27,012,15,541 8.56%?2.47 ? 66,765.34移动应用程序: mCent浏览器-快速和安全加免费数据(Google );mCent https://play.google.com/store/apps/details?id=com.mcent.browser移动应用程序显示-亲和-关键词-主题Display_Keywords 31,898,06,07,897 0.57%?1.77 ? 56,368.85 4月-18移动应用程序:审评委Informer(Dream11,Myteam11提示和IPL新闻)(谷歌播放),https://play.google.com/store/apps/details?id=manager.attendance.fantasycrickettips移动应用程序显示-亲和关键字-Topics Display_Keywords 52,584 61,07,340 0.86%?1.76 ? 92,484.03
我试过所有这些步骤,但都失败了。请帮助提供解决方案或链接。PLease转换为CSV格式
发布于 2018-05-26 05:09:48
试试a.encode('utf-8', 'ignore')。这应该只是删除任何无效的字节。
https://stackoverflow.com/questions/50539458
复制相似问题