Skip to content
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

Format mismatch doesn't coerce to NaT #24763

shuttle1987 opened this issue Jan 14, 2019 · 0 comments


None yet
4 participants
Copy link

commented Jan 14, 2019

Code Sample, a copy-pastable example if possible

>>> pd.to_datetime("00:01:18", format='H%:M%:S%', errors='coerce', infer_datetime_format=False)

Problem description

In this example code I have made a mistake with the format 'H%:M%:S%' it should be '%H:%M:%S'
instead. Since I have specified errors to 'coerce' getting a string as the return value here seems very surprising to me.

Expected Output

Given that I have specified errors='coerce' and infer_datetime_format=False I'd expect to get a NaT result here.

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]

commit: None
python-bits: 64
OS: Linux
OS-release: 4.15.0-1031-aws
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None

pandas: 0.23.4
pytest: 3.8.0
pip: 18.1
setuptools: 40.2.0
Cython: 0.28.5
numpy: 1.15.1
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 6.5.0
sphinx: 1.7.9
patsy: 0.5.0
dateutil: 2.7.3
pytz: 2018.5
blosc: None
bottleneck: 1.2.1
tables: 3.4.4
numexpr: 2.6.8
feather: None
matplotlib: 2.2.3
openpyxl: 2.5.6
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 1.1.0
lxml: 4.2.5
bs4: 4.6.3
html5lib: 1.0.1
sqlalchemy: 1.2.11
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

@TomAugspurger TomAugspurger added this to the Contributions Welcome milestone Jan 14, 2019

@WillAyd WillAyd added the Bug label Jan 14, 2019

@sinhrks sinhrks referenced this issue Jan 17, 2019


BUG: Format mismatch doesn't coerce to NaT #24815

4 of 4 tasks complete

@jreback jreback modified the milestones: Contributions Welcome, 0.24.0 Jan 17, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.