BUG: ISO8601 fastpath fails to parse 2022-01-01 00:00:00Z

This issue has been created since 2022-11-17.

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.

Reproducible Example

pd.to_datetime('2022-01-01 00:00:00Z', format='%Y-%m-%d %H:%M:%S%z')

Issue Description

Note how:

  • in the standard library, %Z corresponds to 'UTC', not to 'Z'
  • Z corresponds to '%z', not to '%Z'
In [6]: pydate = dt.datetime(2022, 11, 17, tzinfo=dt.timezone.utc)

In [7]: dt.datetime.strftime(pydate, '%Y-%m-%d %H:%M:%S%Z')
Out[7]: '2022-11-17 00:00:00UTC'

In [8]: dt.datetime.strptime('2020-01-01T00:00:00Z', '%Y-%m-%dT%H:%M:%S%z')
Out[8]: datetime.datetime(2020, 1, 1, 0, 0, tzinfo=datetime.timezone.utc)

Noticed while fixing merge conflicts in #49024 after having merged #49333

Expected Behavior

The ISO8601-fast-path should allow this string to be parsed with the given format

Installed Versions

INSTALLED VERSIONS

commit : 34b51d94d940f274652f60cf950b9cd2908ab7c3
python : 3.8.13.final.0
python-bits : 64
OS : Linux
OS-release : 5.10.102.1-microsoft-standard-WSL2
Version : #1 SMP Wed Mar 2 00:30:59 UTC 2022
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8

pandas : 2.0.0.dev0+689.g34b51d94d9.dirty
numpy : 1.23.4
pytz : 2022.6
dateutil : 2.8.2
setuptools : 59.8.0
pip : 22.3.1
Cython : 0.29.32
pytest : 7.2.0
hypothesis : 6.56.4
sphinx : 4.5.0
blosc : None
feather : None
xlsxwriter : 3.0.3
lxml.etree : 4.9.1
html5lib : 1.1
pymysql : 1.0.2
psycopg2 : 2.9.3
jinja2 : 3.0.3
IPython : 8.6.0
pandas_datareader: 0.10.0
bs4 : 4.11.1
bottleneck : 1.3.5
brotli :
fastparquet : 0.8.3
fsspec : 2021.11.0
gcsfs : 2021.11.0
matplotlib : 3.6.2
numba : 0.56.3
numexpr : 2.8.3
odfpy : None
openpyxl : 3.0.10
pandas_gbq : 0.17.9
pyarrow : 9.0.0
pyreadstat : 1.2.0
pyxlsb : 1.0.10
s3fs : 2021.11.0
scipy : 1.9.3
snappy :
sqlalchemy : 1.4.43
tables : 3.7.0
tabulate : 0.9.0
xarray : 2022.11.0
xlrd : 2.0.1
zstandard : 0.19.0
tzdata : None
qtpy : None
pyqt5 : None
None

MarcoGorelli wrote this answer on 2022-11-17

Looks like '%Z' was added to the format_is_iso function in https://github.com/pandas-dev/pandas/pull/42068/files

EDIT: this is a separate issue, will open one now

More Details About Repo
Owner Name pandas-dev
Repo Name pandas
Full Name pandas-dev/pandas
Language Python
Created Date 2010-08-24
Updated Date 2022-12-07
Star Count 36164
Watcher Count 1118
Fork Count 15472
Issue Count 3683

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
zsh completion for `tea +pkg` 3 2022-10-29 2022-11-21
Processing extension can't be used for validation? 4 2022-07-14 2022-11-22
Convenience methods for converting STAC objects / linked assets to data containers 9 2022-07-14 2022-11-22
Exception getAllPlayerInfo 0 2021-10-18 2022-05-10
[Addition]: SenseCAP Same maker witnessing cluster 0 2022-05-05 2022-04-28
[Addition]: SenseCAP Same maker witnessing cluster 0 2022-05-05 2022-04-28
[Addition]: Cal-Chip Connected Devices Same maker witnessing cluster 0 2022-05-05 2022-04-28
[Addition]: SenseCAP Same maker witnessing cluster 0 2022-05-05 2022-04-28
Network locations can't be loaded 1 2022-07-01 2022-11-30
Run PlannedReparentShard if primary vttablet is shutting down 0 2022-07-05 2022-11-10
Add Rolling Updates to VTop 0 2022-07-14 2022-11-10
How to configure Windows web server to only accept PIV certificate 1 2019-06-26 2022-10-06
handling of header lines? 0 2022-08-01 2022-09-22
add downport feature directly in transpiler 1 2022-07-13 2022-09-22
option to include source code in compiled code 0 2022-08-09 2022-09-30
unable to use librosa (package for music/audio analysis) 3 2021-12-10 2022-11-09
Release new PartiQL version from 0.6.1 0 2022-06-22 2022-11-22
Crashes On Loading The 3D Editor 2 2021-10-16 2022-09-12
Memory leak when attaching event handlers from Python 6 2022-10-13 2022-11-18
Is there a way to get the Onedrive/SharePoint token without prompting for credentials 1 2018-09-30 2022-09-23
[GCS] Access to directory DIODE_data 3 2021-12-24 2022-10-18
Bad results of generating images of KITTI dataset 7 2021-12-14 2022-10-17
Try on two stage detector 1 2021-12-09 2022-10-18
Annotations that reference multiple classes are not correctly exposed as part of the public ABI 2 2022-08-11 2022-11-18
Option arguments should be treated differently 0 2022-09-09 2022-11-09
Error when using ASA 2.10.2 and MRTK 2.7.2 for Android builds 0 2021-10-20 2022-09-09
Selling tokens is not working 7 2021-05-31 2022-11-22
Permintaan fitur: Pindahkan halaman statis untuk website (front) ke masing-masing tema 1 2022-02-11 2022-10-01
关于标记-清除算法的疑问 8 2018-12-02 2021-12-29
https://twitter.com/agakasiri?t=cBQY04d9sqTcG11gCM9O0Q&s=09 0 2022-08-11 2022-12-05
How do I change the size of the cropper UI? 3 2021-10-04 2022-09-08
我的简悦无法设置快捷键进入阅读模式。 1 2021-09-23 2022-01-12
Transparent Multicluster: pcluster health checks 14 2021-12-03 2022-12-05
Cash On Delivery 9 2021-05-13 2022-01-13
Undefined variable $--button-primary-font-color... 1 2021-09-16 2022-12-02
Blockchain technologies 2 2021-06-02 2022-11-10
Dynamo Crashed 1 2021-01-23 2021-11-12
CodeceptJS: Allure report always opens the latest report - Multiple Browser Execution 6 2022-07-31 2022-12-04
outputStandalone breaking with middleware 2 2022-01-01 2022-07-14
https://github.com/twilio/twilio-conversations-demo-kotlin/ 1 2021-05-06 2022-12-04
Encoder-Decoder model after fine tuning on Turkish dataset, generation gives the same results regardless of the input 17 2022-05-07 2022-08-30
Argument of type 'string' is not assignable to parameter of type 'SetStateAction<never[]>' 2 2021-03-14 2022-10-18
Typo in Wi-Fi Hacking 101 – How to Hack WPA2 and Defend Against These Attacks Article 3 2022-11-27 2022-12-03
Ability to log in using administrator account,but can't "Get configuration fiels" 0 2019-03-21 2022-12-07
Revert Vcm specification for AIB Gen1 to Vos / 2 1 2021-02-03 2022-11-10
[SC-7] Restrict egress traffic from catalog 12 2022-04-19 2022-10-22
database issue (Energy data) 2 2022-11-02 2022-11-03
Mac operating problems 1 2021-01-16 2022-09-13
ThemeRiver series click has incorrect data 2 2021-09-20 2022-11-16
Bump node-notifier from 5.1.2 to 8.0.1 0 2020-12-21 2022-10-19