-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: Confusing error message when to_datetime
fails for times
#46509
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
It returns the following
If it is hour data you can directly pass them as integers (like 11), there is no need to put (like 11:00) in this format and then specify the unit parameter to tell it is hour data. Then it'll return the time stamp from the default timestamp.
Output:
Or else you can pass a time stamp you like by using origin parameter. I hope it'll help you!!! |
take |
Thanks for the report I think the simplest approach could be to modify Lines 670 to 671 in cedd122
so that If anyone can come up with a good error message and wants to submit a pull request, that would be welcome EDIT this might not be that simple, actually |
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
(Still working on checking the
main
branch, getting a build is taking me a while)Reproducible Example
Issue Description
Basically: the error message for
pandas._libs.tslibs.np_datetime.OutOfBoundsDatetime
is confusing.I was doing something like this:
which printed:
Which wasn't helpful for diagnosing my error.
Instead I had to do this to find the incorrect
11:0
value:Expected Behavior
Something like:
Installed Versions
INSTALLED VERSIONS
commit : 06d2301
python : 3.8.8.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-105-generic
Version : #119~18.04.1-Ubuntu SMP Tue Mar 8 11:21:24 UTC 2022
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.4.1
numpy : 1.19.3
pytz : 2021.1
dateutil : 2.8.1
pip : 22.0.4
setuptools : 52.0.0.post20210125
Cython : 0.29.23
pytest : 6.2.4
hypothesis : None
sphinx : 4.1.2
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.0.3
IPython : 7.26.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.4.1
numba : 0.53.1
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.6.3
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None
The text was updated successfully, but these errors were encountered: