Skip to content

DataFrame Shift with axis=1 gives error #6371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gouthambs opened this issue Feb 16, 2014 · 1 comment · Fixed by #6373
Closed

DataFrame Shift with axis=1 gives error #6371

gouthambs opened this issue Feb 16, 2014 · 1 comment · Fixed by #6373
Labels
Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Milestone

Comments

@gouthambs
Copy link
Contributor

I was playing with axis 0 and 1 in DataFrame shift. I get the following error:

import numpy as np
import pandas as pd
df = pd.DataFrame(np.random.rand(10,5))
df.shift(1,axis=1)

This gives me an error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\WinPython-32bit-2.7.6.3\python-2.7.6\lib\site-packages\pandas\core\generic.py", line 3175, in shift
    new_data = self._data.shift(indexer, periods, axis=block_axis)
  File "c:\WinPython-32bit-2.7.6.3\python-2.7.6\lib\site-packages\pandas\core\internals.py", line 2407, in shift
    return self.apply('shift', *args, **kwargs)
  File "c:\WinPython-32bit-2.7.6.3\python-2.7.6\lib\site-packages\pandas\core\internals.py", line 2375, in apply
    applied = getattr(blk, f)(*args, **kwargs)
  File "c:\WinPython-32bit-2.7.6.3\python-2.7.6\lib\site-packages\pandas\core\internals.py", line 918, in shift
    new_values = self.values.take(indexer, axis=axis)
IndexError: index 5 is out of bounds for size 5

I am using pandas 0.13.1

@jreback
Copy link
Contributor

jreback commented Feb 16, 2014

thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Missing-data np.nan, pd.NaT, pd.NA, dropna, isnull, interpolate
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants