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

解决《利用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

原文地址:https://www.cnblogs.com/sggggr/p/12248357.html