pythondataframe取⼀列_PythonpandasDataFrame⽆法获得
第⼀列数据
我⽤Pandas做数据处理,遇到⼀个问题,它不能得到第⼀列数据,但是可以得到其他列数据,为什么?我怎么能解决这个问题,有⼈能帮忙吗?
python怎么读取excel某一列我刚刚导⼊了excel⽂件的数据,并希望通过以下⽅法获得名称数据(第⼀列)data['Name']
错误如下所⽰KeyError Traceback (most recent call last)
/Users/test/anaconda/lib/python3.6/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance)
2392 try:
-> 2393 return self.__loc(key)
2394 except KeyError:
pandas/_libs/index.pyx in pandas._libs._loc (pandas/_libs/index.c:5239)()
pandas/_libs/index.pyx in pandas._libs._loc (pandas/_libs/index.c:5085)()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs._item
(pandas/_libs/hashtable.c:20405)()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs._item
(pandas/_libs/hashtable.c:20359)()
KeyError: 'Name'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
in ()
----> 1 school_names = processing['Name']
/Users/test/anaconda/lib/python3.6/site-packages/pandas/core/frame.py in __getitem__(self, key)
2060 return self._getitem_multilevel(key)
2061 else:
-> 2062 return self._getitem_column(key)
2063
2064 def _getitem_column(self, key):
/
Users/test/anaconda/lib/python3.6/site-packages/pandas/core/frame.py in _getitem_column(self, key)
2067 # get column
2068 lumns.is_unique:
-> 2069 return self._get_item_cache(key)
2070
2071 # duplicate columns & possible reduce dimensionality
/Users/test/anaconda/lib/python3.6/site-packages/pandas/core/generic.py in _get_item_cache(self, item)
1532 res = (item)
1533 if res is None:
-> 1534 values = self._(item)
1535 res = self._box_item_values(item, values)
1536 cache[item] = res
/Users/test/anaconda/lib/python3.6/site-packages/pandas/core/internals.py in get(self, item, fastpath)
3588
3589 if not isnull(item):
-> 3590 loc = _loc(item)
3591 else:
3592 indexer = np.arange(len(self.items))[isnull(self.items)]
/Users/test/anaconda/lib/python3.6/site-packages/pandas/core/indexes/base.py in get_loc(self, key, method, tolerance) 2393 return self.__loc(key)
2394 except KeyError:
-> 2395 return self.__loc(self._maybe_cast_indexer(key))
2396
2397 indexer = _indexer([key], method=method, tolerance=tolerance)
pandas/_libs/index.pyx in pandas._libs._loc (pandas/_libs/index.c:5239)() pandas/_libs/index.pyx in pandas._libs._loc (pandas/_libs/index.c:5085)()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs._item (pandas/_libs/hashtable.c:20405)()
pandas/_libs/hashtable_class_helper.pxi in pandas._libs._item (pandas/_libs/hashtable.c:20359)()
KeyError: 'Name'

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。