-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Passing datetime strings of the form "1-01-01 00:00:00" #37071
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
I have put a failing test in #37070 in case that is helpful |
We indeed rely here on the behaviour of Note that specifying the year as 4 numbers gives the expected result:
Funny (or ironic ..) thing is that the error message actually shows the datetime in the format you are using / doesn't work. I was going to say that if you don't want to rely on "inferring" the date from |
Ok in that case I'll add an issue in that repo and let's see what happens. |
Having thought about it more and looked through dateutil, it is indeed ambiguous (e.g. 2-03-04 could be 2nd March year 4 or 2nd March 2004 or 4th March year 2) so I'll go up the chain instead to where this originally arose (xarray). Thanks for your help @jorisvandenbossche 👍 |
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.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
Problem description
Passing "1-01-01 00:00:00" to "2001-01-01 00:00:00" is clearly wrong, this should raise an out of bounds datetime error.
Expected Output
However, the problem here appears to be deeper than pandas, specifically
If it's helpful, I'm happy to raise an issue in https://github.com/dateutil/dateutil instead. It's not super clear to me where the error really is (maybe dateutil have a very good reason for parsing "1-01-01 00:00:00" as "2001-01-01 00:00:00").
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : cd88ee2
python : 3.8.5.final.0
python-bits : 64
OS : Darwin
OS-release : 18.7.0
Version : Darwin Kernel Version 18.7.0: Mon Aug 31 20:53:32 PDT 2020; root:xnu-4903.278.44~1/RELEASE_X86_64
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : en_AU.UTF-8
LOCALE : en_AU.UTF-8
pandas : 1.2.0.dev0+746.gcd88ee2dd
numpy : 1.19.2
pytz : 2020.1
dateutil : 2.8.1
pip : 20.2.3
setuptools : 49.1.0.post20200704
Cython : 0.29.21
pytest : 6.1.1
hypothesis : 5.37.1
sphinx : 3.2.1
blosc : None
feather : None
xlsxwriter : 1.3.6
lxml.etree : 4.5.2
html5lib : 1.1
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : 7.18.1
pandas_datareader: None
bs4 : 4.9.3
bottleneck : 1.3.2
fsspec : 0.8.3
fastparquet : 0.4.0
gcsfs : 0.7.1
matplotlib : 3.2.2
numexpr : 2.7.1
odfpy : None
openpyxl : 3.0.5
pandas_gbq : None
pyarrow : 0.17.1
pytables : None
pyxlsb : None
s3fs : 0.4.2
scipy : 1.5.1
sqlalchemy : 1.3.19
tables : 3.6.1
tabulate : 0.8.7
xarray : 0.15.1
xlrd : 1.2.0
xlwt : 1.3.0
numba : 0.48.0
The text was updated successfully, but these errors were encountered: