使用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 raiseKeyError 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)))警告消失