-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Date offset on numpy datetime64 does not work for week and month offsets #41617
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
A possible workaround to this can be to use the import numpy as np
import pandas as pd
ts_np = np.Datetime64('2021-01-01T08:00:00.00')
do = np.timedelta64(1, 'W')
ts_np + do Output:
|
This should be fixed by defining |
#44532 fixed this behavior but only implemented tests for ops with td64. A PR adding tests from the OP would close this. |
When performing this code, it does not give the correct result. import pandas as pd
import numpy as np
ts_np = np.Datetime64('2021-01-01T08:00:00.00')
do=pd.tseries.frequencies.to_offset('1W')
ts_np + do Result:
This is only two days and not the full week. Is this how it is supposed to work? |
|
take |
* TST: add test for compatibility with numpy datetime64 pandas-dev#41617 * TST; add test for compatibility with numpy datetime64 (pandas-dev#41617) * Fixed a fat finger error in one of the expected values * Fixes from pre-commit [automated commit] * changed numpy import
* TST: add test for compatibility with numpy datetime64 pandas-dev#41617 * TST; add test for compatibility with numpy datetime64 (pandas-dev#41617) * Fixed a fat finger error in one of the expected values * Fixes from pre-commit [automated commit] * changed numpy import
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Code Sample
Result
Timestamp('2021-01-01 09:00:00')
Result
Result
Problem description
Applying week or month offset on numpy
Datetime64
does not work.Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 2cb9652
python : 3.8.5.final.0
python-bits : 64
OS : Linux
OS-release : 5.8.0-53-generic
Version : #60~20.04.1-Ubuntu SMP Thu May 6 09:52:46 UTC 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : fr_FR.UTF-8
LOCALE : fr_FR.UTF-8
pandas : 1.2.4
numpy : 1.20.1
pytz : 2021.1
dateutil : 2.8.1
pip : 21.1.1
setuptools : 52.0.0.post20210125
Cython : 0.29.23
pytest : 6.2.3
hypothesis : None
sphinx : 4.0.1
blosc : None
feather : None
xlsxwriter : 1.3.8
lxml.etree : 4.6.3
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 3.0.0
IPython : 7.22.0
pandas_datareader: None
bs4 : 4.9.3
bottleneck : 1.3.2
fsspec : 0.9.0
fastparquet : 0.6.0
gcsfs : None
matplotlib : 3.3.4
numexpr : 2.7.3
odfpy : None
openpyxl : 3.0.7
pandas_gbq : None
pyarrow : 2.0.0
pyxlsb : None
s3fs : None
scipy : 1.6.2
sqlalchemy : 1.4.15
tables : 3.6.1
tabulate : None
xarray : None
xlrd : 2.0.1
xlwt : 1.3.0
numba : 0.51.2
The text was updated successfully, but these errors were encountered: