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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM