0

ValueError: index must be monotonic increasing or decreasing [Jupyter Notebook Image][1]

I am practicing the above code snippet from the book python for data analysis by Wes McKinney

I create a DataFrame like this

frame=DataFrame(np.arange(9).reshape((3,3)), index=['a','c','d'], columns=['Ohio','Texas','California'])

when I try to reindex it like this:

states=['Texas','Utah','California']
frame.reindex(index=['a','b','c','d'],method='ffill', columns=states)

why is ValueError being raised?

Ravi
  • 11
  • 1

1 Answers1

1

You can use

frame.reindex(index=['a', 'b', 'c', 'd'], columns=states).ffill()
Puyi
  • 11
  • 2