-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Error when adding 'm' to a Series of strings #28658
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
Comments
In c4489c the latest commit now, the problem seems gone. INSTALLED VERSIONScommit : c4489cb pandas : 0.26.0.dev0+432.gc4489cbfa |
It seems to be fixed on master, indeed (but can also confirm that it was failing on 0.25.1). I am not sure if this was fixed intentionally, so it might be good to add a test to ensure this keeps working in the future. Somebody wants to do a PR to add a test? |
adds a test to check for regressions later.
adds a test to check for regressions later.
Code Sample
I have found a strange corner case when adding strings to a Series. This is an operation that most of the times works well:
output:
But in the specific case of adding the string 'm', it raises an exception:
output:
Problem description
It took me a while to figure this one out, but looking at the source code of _arith_method_SERIES() in pandas/pandas/core/ops/init.py, it's apparently due to running is_timedelta64_dtype() as part of type checks for the scalar. String 'm' is incorrectly parsed as a timedelta64.
This can be traced to a pandas_dtype() function:
Presumably there are other random strings with similar interactions with type checking functions that throw similar errors in this operation.
I get this error on build 25.1 . I haven't been able to test this on the latest master code, which introduces a lot of changes to /pandas/core/ops/init , so I don't know if this is still a problem there.
Expected Output
Adding strings to a string Series shouldn't throw this exception.
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.6.6.final.0
python-bits : 64
OS : Darwin
OS-release : 18.6.0
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8
pandas : 0.25.1
numpy : 1.17.2
pytz : 2019.2
dateutil : 2.8.0
pip : 10.0.1
setuptools : 39.0.1
Cython : None
pytest : 5.1.2
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : 2.8.3 (dt dec pq3 ext lo64)
jinja2 : 2.10.1
IPython : 7.8.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 0.14.1
pytables : None
s3fs : None
scipy : 1.3.1
sqlalchemy : 1.3.8
tables : None
xarray : None
xlrd : 1.2.0
xlwt : None
xlsxwriter : None
The text was updated successfully, but these errors were encountered: