Python 코딩 Master Course - Advance 11강 질문

 

 

  • 과정명: Python 코딩 Master Course - Advance 11강 질문
  • 강사명: 신동욱 강사님

강의중에 코드 치신거

print(life_exp.loc[range(2000,2010),  ])

똑같이 입력하고 실행시켰는데 

이런 요류가 뜨는데 무슨 문제인거죠????

--------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-35-6577c7af7407> in <module>
----> 1 print(life_exp.loc[range(2000,2010), ])

~\anaconda3\lib\site-packages\pandas\core\indexing.py in __getitem__(self, key)
   1759                 except (KeyError, IndexError, AttributeError):
   1760                     pass
-> 1761             return self._getitem_tuple(key)
   1762         else:
   1763             # we by definition only have the 0th axis

~\anaconda3\lib\site-packages\pandas\core\indexing.py in _getitem_tuple(self, tup)
   1278         # ugly hack for GH #836
   1279         if self._multi_take_opportunity(tup):
-> 1280             return self._multi_take(tup)
   1281 
   1282         # no shortcut needed

~\anaconda3\lib\site-packages\pandas\core\indexing.py in _multi_take(self, tup)
   1337         d = {
   1338             axis: self._get_listlike_indexer(key, axis)
-> 1339             for (key, axis) in zip(tup, o._AXIS_ORDERS)
   1340         }
   1341         return o._reindex_with_indexers(d, copy=True, allow_dups=True)

~\anaconda3\lib\site-packages\pandas\core\indexing.py in <dictcomp>(.0)
   1337         d = {
   1338             axis: self._get_listlike_indexer(key, axis)
-> 1339             for (key, axis) in zip(tup, o._AXIS_ORDERS)
   1340         }
   1341         return o._reindex_with_indexers(d, copy=True, allow_dups=True)

~\anaconda3\lib\site-packages\pandas\core\indexing.py in _get_listlike_indexer(self, key, axis, raise_missing)
   1550 
   1551         self._validate_read_indexer(
-> 1552             keyarr, indexer, o._get_axis_number(axis), raise_missing=raise_missing
   1553         )
   1554         return keyarr, indexer

~\anaconda3\lib\site-packages\pandas\core\indexing.py in _validate_read_indexer(self, key, indexer, axis, raise_missing)
   1652             if not (ax.is_categorical() or ax.is_interval()):
   1653                 raise KeyError(
-> 1654                     "Passing list-likes to .loc or [] with any missing labels "
   1655                     "is no longer supported, see "
   1656                     "https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#deprecate-loc-reindex-listlike"  # noqa:E501

KeyError: 'Passing list-likes to .loc or [] with any missing labels is no longer supported, see https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#deprecate-loc-reindex-listlike'

 

0

댓글

댓글 1개
날짜 투표수
  • 안녕하세요.

     

    해당 명령어는 이제 사용하지 못한다고 나오는 에러네요. (파이썬 문법이 변경되어 나오는 에러)

    그 줄은 삭제하시고 진행하시면 됩니다.

     

    감사합니다.

    0

댓글을 남기려면 로그인하세요.

 

원하는 것을 찾지 못하셨나요?

질문하기