微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

读取CSV文件

如何解决读取CSV文件

import numpy as np
import pandas as pd

df = pd.read_csv('/content/Glassdoor Reviews.csv',encoding='latin1',error_bad_lines=False,sep=';')
df.head()

nullcheck=df.isnull().sum()
print(nullcheck)

count=df['Category'].value_counts()
print(count)

from sklearn.model_selection import train_test_split
X = df['Review']  # this time we want to look at the text
y = df['Category']
X_train,X_test,y_train,y_test = train_test_split(X,y,test_size=0.2,random_state=20)
                   ERROR

` 分类评论,备注0 dtype:int64 b'跳过第170行:预期1场,看到2 \ n'

KeyError跟踪(最近一次通话最近) get_loc中的/usr/local/lib/python3.6/dist-packages/pandas/core/indexes/base.py(自身,键,方法,公差) 2645试试: -> 2646返回self._engine.get_loc(key) 2647除了KeyError:

pandas._libs.index.IndexEngine.get_loc()中的

pandas / _libs / index.pyx

pandas._libs.index.IndexEngine.get_loc()中的

pandas / _libs / index.pyx

pandas中的pandas / _libs / hashtable_class_helper.pxi._libs.hashtable.PyObjectHashTable.get_item()

pandas中的pandas / _libs / hashtable_class_helper.pxi._libs.hashtable.PyObjectHashTable.get_item()

KeyError:'类别'

在处理上述异常期间,发生了另一个异常:

KeyError跟踪(最近一次通话最近) 2帧 get_loc中的/usr/local/lib/python3.6/dist-packages/pandas/core/indexes/base.py(自身,键,方法,公差) 2646返回self._engine.get_loc(键) 2647除了KeyError: -> 2648返回self._engine.get_loc(self._maybe_cast_indexer(key)) 2649 indexer = self.get_indexer([key],method = method,tolerance = tolerance) 2650,如果indexer.ndim> 1或indexer.size> 1:

pandas._libs.index.IndexEngine.get_loc()中的

pandas / _libs / index.pyx

pandas._libs.index.IndexEngine.get_loc()中的

pandas / _libs / index.pyx

pandas中的pandas / _libs / hashtable_class_helper.pxi._libs.hashtable.PyObjectHashTable.get_item()

pandas中的pandas / _libs / hashtable_class_helper.pxi._libs.hashtable.PyObjectHashTable.get_item()

KeyError:“类别” `

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。