Series使用中出现Passing list-likes to .loc or [] with any missing label will raise KeyError in the future

使用Series出现警告:

原代码:

series[list(range(1,5))]

C:\Python36\lib\site-packages\pandas\core\series.py:696: FutureWarning: 

Passing list-likes to .loc or [] with any missing label will raise
KeyError in the future, you can use .reindex() as an alternative.


See the documentation here:
http://pandas.pydata.org/pandas-docs/stable/indexing.html#deprecate-loc-reindex-listlike

  return self.loc[key]


解决办法:

series.reindex(list(range(1,5)))
警告消失



你可能感兴趣的:(数据挖据,机器学习,Python)