You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just tried to pass axis=1 on a shift call to a dataframe and it threw an error, I couldn't find an issue here and this is the first time I tried this function so not sure if this was something that used to work and then got broken.
I'm using python 64-bit 3.3.4, pandas 0.14.1 and numpy 1.8.1
In [57]:
df = pd.DataFrame({'a':randn(10), 'b':randn(10)})
df.shift(axis=1)
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-57-160107eee7e4> in <module>()
1 df = pd.DataFrame({'a':randn(10), 'b':randn(10)})
----> 2 df.shift(axis=1)
C:\WinPython-64bit-3.3.5.0\python-3.3.5.amd64\lib\site-packages\pandas\core\generic.py in shift(self, periods, freq, axis, **kwds)
3173 block_axis = self._get_block_manager_axis(axis)
3174 indexer = com._shift_indexer(len(self), periods)
-> 3175 new_data = self._data.shift(indexer, periods, axis=block_axis)
3176 else:
3177 return self.tshift(periods, freq, **kwds)
C:\WinPython-64bit-3.3.5.0\python-3.3.5.amd64\lib\site-packages\pandas\core\internals.py in shift(self, *args, **kwargs)
2405
2406 def shift(self, *args, **kwargs):
-> 2407 return self.apply('shift', *args, **kwargs)
2408
2409 def fillna(self, *args, **kwargs):
C:\WinPython-64bit-3.3.5.0\python-3.3.5.amd64\lib\site-packages\pandas\core\internals.py in apply(self, f, *args, **kwargs)
2373
2374 else:
-> 2375 applied = getattr(blk, f)(*args, **kwargs)
2376
2377 if isinstance(applied, list):
C:\WinPython-64bit-3.3.5.0\python-3.3.5.amd64\lib\site-packages\pandas\core\internals.py in shift(self, indexer, periods, axis)
916 """ shift the block by periods, possibly upcast """
917
--> 918 new_values = self.values.take(indexer, axis=axis)
919 # convert integer to float if necessary. need to do a lot more than
920 # that, handle boolean etc also
IndexError: index 2 is out of bounds for size 2
In [57]:
df = pd.DataFrame({'a':randn(10), 'b':randn(10)})
df.shift(axis=1)
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-57-160107eee7e4> in <module>()
1 df = pd.DataFrame({'a':randn(10), 'b':randn(10)})
----> 2 df.shift(axis=1)
C:\WinPython-64bit-3.3.5.0\python-3.3.5.amd64\lib\site-packages\pandas\core\generic.py in shift(self, periods, freq, axis, **kwds)
3173 block_axis = self._get_block_manager_axis(axis)
3174 indexer = com._shift_indexer(len(self), periods)
-> 3175 new_data = self._data.shift(indexer, periods, axis=block_axis)
3176 else:
3177 return self.tshift(periods, freq, **kwds)
C:\WinPython-64bit-3.3.5.0\python-3.3.5.amd64\lib\site-packages\pandas\core\internals.py in shift(self, *args, **kwargs)
2405
2406 def shift(self, *args, **kwargs):
-> 2407 return self.apply('shift', *args, **kwargs)
2408
2409 def fillna(self, *args, **kwargs):
C:\WinPython-64bit-3.3.5.0\python-3.3.5.amd64\lib\site-packages\pandas\core\internals.py in apply(self, f, *args, **kwargs)
2373
2374 else:
-> 2375 applied = getattr(blk, f)(*args, **kwargs)
2376
2377 if isinstance(applied, list):
C:\WinPython-64bit-3.3.5.0\python-3.3.5.amd64\lib\site-packages\pandas\core\internals.py in shift(self, indexer, periods, axis)
916 """ shift the block by periods, possibly upcast """
917
--> 918 new_values = self.values.take(indexer, axis=axis)
919 # convert integer to float if necessary. need to do a lot more than
920 # that, handle boolean etc also
IndexError: index 2 is out of bounds for size 2
The text was updated successfully, but these errors were encountered:
alan-wong
changed the title
df.shift(axis=1) complains about index out of range
BUG: df.shift(axis=1) complains about index out of range
Aug 10, 2014
this works in 0.14.1 (on 3.3,numpy 1.8, on windows). Looking at the code that you are showing in the error, that looks like some prior code (this was changed in 0.14.0), see #6672. Pls verify that you are actually importing 0.14.1.
Argh.. so sorry Jeff, I'm actually running 0.13.1, I thought my laptop was running the same version as my desktop which is running 0.14.1. My apologies, thanks for the quick response, how do I close this?
I just tried to pass
axis=1
on a shift call to a dataframe and it threw an error, I couldn't find an issue here and this is the first time I tried this function so not sure if this was something that used to work and then got broken.I'm using python 64-bit 3.3.4, pandas 0.14.1 and numpy 1.8.1
The text was updated successfully, but these errors were encountered: