pandas索引問題:data["wmc"]["0"]

KeyError Traceback (most recent call last)
in
----> 1 data[“wmc”][“0”]

d:\chenjb\develop\python37\lib\site-packages\pandas\core\series.py in getitem(self, key)
866 key = com.apply_if_callable(key, self)
867 try:
–> 868 result = self.index.get_value(self, key)
869
870 if not is_scalar(result):

d:\chenjb\develop\python37\lib\site-packages\pandas\core\indexes\base.py in get_value(self, series, key)
4373 try:
4374 return self._engine.get_value(s, k,
-> 4375 tz=getattr(series.dtype, ‘tz’, None))
4376 except KeyError as e1:
4377 if len(self) > 0 and (self.holds_integer() or self.is_boolean()):

pandas_libs\index.pyx in pandas._libs.index.IndexEngine.get_value()

pandas_libs\index.pyx in pandas._libs.index.IndexEngine.get_value()

pandas_libs\index.pyx in pandas._libs.index.IndexEngine.get_loc()

pandas_libs\index_class_helper.pxi in pandas._libs.index.Int64Engine._check_type()

KeyError: ‘0’

解決辦法:
import pandas as pd
path =’./Desktop/tmp1/xerces-1.2.csv’
data = pd.read_csv(path)
data[“wmc”][2]

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章