numpy - ValueError: index must be monotonic increasing or decreasing -


ser3 = series(['usa','mexico','canada'],index = ['0','5','10'])

here ranger = range(15)

i error while using forward fill in ipython

ser3.reindex(ranger,method = 'ffill')

/users/varun/anaconda/lib/python2.7/site-packages/pandas/core/index.pyc in _searchsorted_monotonic(self, label, side)    2395             return len(self) - pos    2396  -> 2397         raise valueerror('index must monotonic increasing or decreasing')    2398     2399     def get_slice_bound(self, label, side, kind):  valueerror: index must monotonic increasing or decreasing 

there's original index being string , not numeric. if change original index numeric (e.g., index=[0, 5, 10]), works correctly.

in [1]: pandas import series    ...: ser3 = series(['usa','mexico','canada'],index = [0,5,10])    ...: ranger = range(15)    ...: ser3.reindex(ranger,method = 'ffill')    ...:  out[1]:  0        usa 1        usa 2        usa 3        usa 4        usa 5     mexico 6     mexico 7     mexico 8     mexico 9     mexico 10    canada 11    canada 12    canada 13    canada 14    canada dtype: object 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -