Skip to content

BUG: Pandas sets current time if you do not set it #44573

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

Closed
2 of 3 tasks
Jakub-Ner opened this issue Nov 22, 2021 · 2 comments
Closed
2 of 3 tasks

BUG: Pandas sets current time if you do not set it #44573

Jakub-Ner opened this issue Nov 22, 2021 · 2 comments
Labels
Closing Candidate May be closeable, needs more eyeballs Usage Question

Comments

@Jakub-Ner
Copy link

  • 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 master branch of pandas.

Reproducible Example

import pandas as pd

hour = pd.DataFrame({"hour": ["09:00", "12:37"]})
hour["hour"] = pd.to_datetime(hour["hour"])
print(hour["hour"].dt.date) # display current time

Issue Description

Pandas sets current time if you do not set it by yourself.

Expected Behavior

if you don't set a date you expect it to be NaN

Installed Versions

INSTALLED VERSIONS

commit : 945c9ed
python : 3.8.10.final.0
python-bits : 64
OS : Linux
OS-release : 5.11.0-40-generic
Version : #44~20.04.2-Ubuntu SMP Tue Oct 26 18:07:44 UTC 2021
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 1.3.4
numpy : 1.21.4
pytz : 2020.1
dateutil : 2.7.3
pip : 20.0.2
setuptools : 45.2.0
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.2
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : 3.5.0
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : 1.3.18
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
None

@Jakub-Ner Jakub-Ner added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Nov 22, 2021
@MarcoGorelli
Copy link
Member

I think this is due to dateutil

>>> from dateutil.parser import parse
>>> parse('09:00')
datetime.datetime(2021, 11, 22, 9, 0)

You should specify the format if you expect it to error if it doesn't match the format

@MarcoGorelli MarcoGorelli added Closing Candidate May be closeable, needs more eyeballs Usage Question and removed Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Nov 22, 2021
@mroeschke
Copy link
Member

Correct, this is inherited behavior from dateutil. Closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closing Candidate May be closeable, needs more eyeballs Usage Question
Projects
None yet
Development

No branches or pull requests

3 participants