Skip to content

DataFrame Shift with axis=1 gives error #6371

Closed
@gouthambs

Description

@gouthambs

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolate

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions