Skip to content
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

BUG: ValueError in Series.divmod #25557

danielplawrence opened this issue Mar 5, 2019 · 1 comment


Copy link

commented Mar 5, 2019

Code Sample, a copy-pastable example if possible

import pandas as pd
import numpy as np
a = pd.Series([1, 1, 1, np.nan], index=['a', 'b', 'c', 'd'])
b = pd.Series([1, np.nan, 1, np.nan], index=['a', 'b', 'd', 'e'])



Problem description

divmod(series_a,series_b) works as expected, but series_a.divmod(b) returns the following error:

>>> a.divmod(b)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/danlaw/Projects/pandas/pandas/core/", line 1892, in flex_wrapper
    return self._binop(other, op, level=level, fill_value=fill_value)
  File "/Users/danlaw/Projects/pandas/pandas/core/", line 2522, in _binop
    result = self._constructor(result, index=new_index, name=name)
  File "/Users/danlaw/Projects/pandas/pandas/core/", line 250, in __init__
    .format(val=len(data), ind=len(index)))
ValueError: Length of passed values is 2, index implies 4

Expected Output

(a    0.0
b    0.0
c    NaN
d    NaN
e    NaN
dtype: float64, a    1.0
b    1.0
c    NaN
d    NaN
e    NaN
dtype: float64)

Output of pd.show_versions()

commit: 221be3b python: python-bits: 64 OS: Darwin OS-release: 16.7.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: en_US.UTF-8 LOCALE: en_US.UTF-8

pandas: 0.25.0.dev0+200.g221be3b4a
pytest: 4.3.0
pip: 19.0.3
setuptools: 40.8.0
Cython: 0.29.5
numpy: 1.16.2
scipy: 1.2.1
pyarrow: 0.11.1
xarray: 0.11.3
IPython: 7.3.0
sphinx: 1.8.4
patsy: 0.5.1
dateutil: 2.8.0
pytz: 2018.9
blosc: None
bottleneck: 1.2.1
tables: 3.4.4
numexpr: 2.6.9
feather: None
matplotlib: 3.0.2
openpyxl: 2.6.0
xlrd: 1.2.0
xlwt: 1.3.0
xlsxwriter: 1.1.5
lxml.etree: 4.3.1
bs4: 4.7.1
html5lib: 1.0.1
sqlalchemy: 1.2.18
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: 0.2.0
fastparquet: 0.2.1
pandas_gbq: None
pandas_datareader: None
gcsfs: None


This comment has been minimized.

Copy link

commented Mar 7, 2019

I will look at this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.