I wrote the following code:
frame1=DataFrame(np.arange(9).reshape(3,3), index=['a','b','c'],
columns=['Ohio','Texas','California']), states=
['Texas','Utah','California']
Then,
frame1.reindex(index=['a','b','c','d'],method='ffill',columns=states)
It returns an error stating 'index must be monotonic increasing or decreasing
'. I have read the answer to this question.
Then I re-wrote it as
frame1.reindex(index=['a','b','c','d'],method='ffill',columns=states.sort())
.
Now the result is :
Ohio Texas California
a 0 1 2
b 3 4 5
c 6 7 8
d 6 7 8
As you can see, the columns are not changed as I expected. Why here the columns don't change, though I use the reindex function?