Skip to content

ERR: Index.shift() gives confusing error message when no DatetimeIndex #8038

Closed
@jorisvandenbossche

Description

@jorisvandenbossche
In [1]: idx = pd.Index(range(5))

In [2]: idx
Out[2]: Int64Index([0, 1, 2, 3, 4], dtype='int64')

In [3]: idx.shift(1)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-d8362983dbf7> in <module>()
----> 1 idx.shift(1)

c:\users\vdbosscj\scipy\pandas-joris\pandas\core\index.pyc in shift(self, period
s, freq)
   1096             return self
   1097
-> 1098         offset = periods * freq
   1099         return Index([idx + offset for idx in self], name=self.name)
   1100

TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'

Should shift be allowed at all when it is no DatetimeIndex?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions