Skip to content

Regression: divmod(my_series, some_integer) no longer works since version 0.13. #8174

Closed
@mdickinson

Description

@mdickinson

In Pandas version 0.12, you could apply the Python built-in divmod function to a Series and an integer:

Enthought Canopy Python 2.7.6 | 64-bit | (default, Jun  4 2014, 16:42:26) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>> pd.__version__
'0.12.0'
>>> divmod(pd.Series(range(4)), 2)
(0    0
1    0
2    1
3    1
dtype: int64, 0    0
1    1
2    0
3    1
dtype: int64)
>>> 

With version >= 0.13, it appears that this usage is no longer supported:

Enthought Canopy Python 2.7.6 | 64-bit | (default, Jun  4 2014, 16:42:26) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>> pd.__version__
'0.14.1'
>>> divmod(pd.Series(range(4)), 2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for divmod(): 'Series' and 'int'

Was this change intentional?

Some context: I was using this to read a climate datafile that had a 4-digit column holding combined month and day values. The original code looked something like: month, day = divmod(df['MODA'], 100), but broke after upgrading to version 0.14.

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