-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
bug: merge_asof with tz-aware datetime "by" parameter raises #21184
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
Thanks, I can confirm that this bug is occurring on master. PR to fix is welcome! |
xref #14844 : a similar |
I'd be glad to help, but have no experience in contributing to a big project. So I can try to find a fix when I have time to dive into it, but no promises yet ! :) |
When the
The results are cast to object dtype, but are passed to a cython function that expects a numpy array instead of an Index. A |
here's a patch to fix. prob could use some general refactoring in this routine (maybe), but can do in the future
|
I was actually looking into a fix too this morning, and in the process found out that the bug originated in a typing issue in the following function of pandas/core/generic.py (line 1327) :
The expected return type is a numpy array, but the following (line 1375) :
produces a DateTimeIndex in the case when _values is accessed on a tz-aware datetime Series.
edit: The problem i'm pointing out also yields an error when doing things such as
Sorry for the lack of details, i'm a bit out of time right now, i can elaborate later if needed. |
This looks to be fixed on master now. Could use a test. |
Code Sample
Error traceback
Problem description
Function pandas.merge_asof raises when "by" parameter is provided a column of tz-aware datetime type.
Note that the same code with tz-naive datetimes works :
outputs :
Output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.6.4.final.0
python-bits: 64
OS: Windows
OS-release: 7
machine: AMD64
processor: Intel64 Family 6 Model 60 Stepping 3, GenuineIntel
byteorder: little
LC_ALL: None
LANG: FR
LOCALE: None.None
pandas: 0.23.0
pytest: None
pip: 10.0.1
setuptools: 38.5.1
Cython: None
numpy: 1.14.1
scipy: 1.0.0
pyarrow: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.6.1
pytz: 2018.3
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.9999999
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: