解决《利用python进行数据分析》P139报错问题 index must be monotonic increasing or decreasing

时间:2020-02-01 14:17:20   收藏:0   阅读:140

解决《利用python进行数据分析》P139报错问题 index must be monotonic increasing or decreasing
frame.reindex(index=[‘a‘,‘b‘,‘c‘,‘d‘],method=‘ffill‘,columns=states)
报错:index must be monotonic increasing or decreasing

修改代码:把method=‘ffill’拿出来
注意,是method的方法,参数ffill后面加"()"

frame4=frame.reindex(index=[a,b,c,d],
columns=states).ffill()

结果为:

Texas Utah California
a 1.0 NaN 2.0
b NaN NaN NaN
c 4.0 NaN 5.0
d 7.0 NaN 8.0

————————————————
版权声明:本文为CSDN博主「木里先森」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/mr_muli/article/details/83962897

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!