-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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: replacing out of bound datetimes is not possible #36782
Comments
Related to #34186. |
Workaround: df.applymap(lambda x: datetime(2020, 10, 1) if x == datetime(2920, 10, 1) else x) I would expect |
Hello, I'm interested in solving this bug, I would like to ask a couple of question regarding the behaviour of workaround code and whether these behaviours are expected in the final solution for the bug. Code:
Output:
After reassigning Code:
Ouput:
I would like to know whether the change in dtype of x from I would also like to ask about the loss of precision, as initially While after reassignment I found that time value is not included Output of detailsInstalled Versions
|
take |
In pandas 1.0.4: df = DataFrame({'x': [datetime(2920, 10, 1)]})
df.dtypes Out:
df.replace({datetime(2920, 10, 1): datetime(2020, 10, 1)}).dtypes Out:
Thus, the workaround has the same side-effect as was the behaviour of df.replace({datetime(2920, 10, 1): datetime(2020, 10, 1)}).dtypes |
Cool, I'll look into it. |
This looks to work on master. Could use a test
|
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, a copy-pastable example
Raises:
Full traceback details
Problem description
It is useful to be able to replace the dates which are out of bound, because these are not supported by pandas. However, it is currently difficult because replace no longer works for them. This is a regression as the above code worked well in pandas 1.0.4, but does not work in pandas 1.1.2 nor on master.
Expected Output
df
should be equal toDataFrame({'x': [datetime(2020, 10, 1)]})
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 2a7d332
python : 3.8.1.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-48-generic
Version : #52-Ubuntu SMP Thu Sep 10 10:58:49 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8
pandas : 1.1.2
numpy : 1.18.1
pytz : 2019.3
dateutil : 2.8.1
pip : 20.2.3
setuptools : 41.2.0
Cython : None
pytest : 5.3.4
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 1.2.8
lxml.etree : 4.4.2
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 2.10.3
IPython : 7.11.1
pandas_datareader: None
bs4 : 4.8.2
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.1.2
numexpr : None
odfpy : None
openpyxl : 3.0.3
pandas_gbq : None
pyarrow : None
pytables : None
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : 1.2.0
xlwt : None
numba : 0.49.0
The text was updated successfully, but these errors were encountered: