Skip to content

Series of integers mod behavior #24396

Closed
@andrewgsavage

Description

@andrewgsavage

Code Sample

import pandas as pd

s=pd.Series(range(1,10))
s1=pd.Series("foo")

s1%s


0                                              foo
1    [nan, nan, nan, nan, nan, nan, nan, nan, nan]
2    [nan, nan, nan, nan, nan, nan, nan, nan, nan]
3    [nan, nan, nan, nan, nan, nan, nan, nan, nan]
4    [nan, nan, nan, nan, nan, nan, nan, nan, nan]
5    [nan, nan, nan, nan, nan, nan, nan, nan, nan]
6    [nan, nan, nan, nan, nan, nan, nan, nan, nan]
7    [nan, nan, nan, nan, nan, nan, nan, nan, nan]
8    [nan, nan, nan, nan, nan, nan, nan, nan, nan]
dtype: object




import pandas as pd

s=pd.Series(range(1,10))
s2=pd.Series("foo", index=s.index)

s2%s

0    foo
1    foo
2    foo
3    foo
4    foo
5    foo
6    foo
7    foo
8    foo
dtype: object

Problem description

Was expecting a TypeError.

I think this is breaking a pint pandas interface test which tests s2 arithmetic_op Series(PintArray... raises some exception. (Which is failing on rmod )

import pandas as pd
import numpy as np
import pint
from pint.pandas_interface import PintArray

ureg = pint.UnitRegistry()
Q_ = ureg.Quantity
torque = PintArray(Q_([1, 2, 2, 3, 4, 5], "lbf ft"))
angular_velocity = PintArray(Q_([1000, 2000, 2000, 3000, 3000, 3000], "rpm"))
df = pd.DataFrame({"torque": torque, "angular_velocity": angular_velocity})


pd.Series("foo", index=df.index)%df.torque

0    foo
1    foo
2    foo
3    foo
4    foo
5    foo
dtype: object

Output of pd.show_versions()

INSTALLED VERSIONS

commit: None
python: 3.6.6.final.0
python-bits: 64
OS: Linux
OS-release: 4.4.0-53-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: en_GB.UTF-8

pandas: 0.24.0.dev0+1340.g8c58817bd
pytest: 3.7.1
pip: 10.0.1
setuptools: 40.0.0
Cython: 0.28.5
numpy: 1.15.0
scipy: None
pyarrow: None
xarray: None
IPython: 6.5.0
sphinx: None
patsy: None
dateutil: 2.7.3
pytz: 2018.5
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.1.2
openpyxl: None
xlrd: 1.1.0
xlwt: None
xlsxwriter: 1.0.2
lxml.etree: None
bs4: 4.6.0
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None

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