We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
fmt = '%Y%m%d-%H%M%S-%f%z' ts = '20190129-235348-183747+0000' pd.Timestamp.strptime(ts, fmt)
Traceback (most recent call last): File "/scratch.py", line 6, in <module> pd.Timestamp.strptime(ts, fmt) File "/python/lib/python3.6/_strptime.py", line 576, in _strptime_datetime return cls(*args) File "pandas/_libs/tslibs/timestamps.pyx", line 748, in pandas._libs.tslibs.timestamps.Timestamp.__new__ TypeError: an integer is required
Timestamp.strptime does not support %z. Issue was fixed with pd.to_datetime in #19979.
pd.to_datetime
The same as pd.to_datetime(ts, format=fmt):
pd.to_datetime(ts, format=fmt)
Timestamp('2019-01-29 23:53:48.183747+0000', tz='UTC')
pd.show_versions()
commit: None python: 3.6.8.final.0 python-bits: 64 OS: Linux OS-release: 4.15.0-43-generic machine: x86_64 processor: x86_64 byteorder: little LC_ALL: C.UTF-8 LANG: C.UTF-8 LOCALE: en_US.UTF-8
pandas: 0.24.0 pytest: 4.1.1 pip: 18.1 setuptools: 40.6.3 Cython: 0.29.2 numpy: 1.15.4 scipy: None pyarrow: None xarray: None IPython: 7.2.0 sphinx: 1.8.2 patsy: None dateutil: 2.7.5 pytz: 2018.9 blosc: None bottleneck: None tables: 3.4.4 numexpr: 2.6.9 feather: None matplotlib: 3.0.2 openpyxl: None xlrd: None xlwt: None xlsxwriter: None lxml.etree: 4.3.0 bs4: None html5lib: None sqlalchemy: 1.2.16 pymysql: None psycopg2: None jinja2: 2.10 s3fs: None fastparquet: None pandas_gbq: None pandas_datareader: None gcsfs: None
The text was updated successfully, but these errors were encountered:
Thanks for the report.
The fix is luckily straightforward.
--- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -736,8 +736,8 @@ class Timestamp(_Timestamp): # microsecond[, nanosecond[, tzinfo]]]]]]) ts_input = datetime(ts_input, freq, tz, unit or 0, year or 0, month or 0, day or 0) - nanosecond = hour - tz = minute + nanosecond = minute + tz = hour freq = None
However, we need to make an API change in the Timestamp constructor as well and switch the positions of the tzinfo and nanosecond arguments.
Timestamp
tzinfo
nanosecond
Sorry, something went wrong.
Can I give this a try if no one is working on this?
Go for it, unless @mroeschke was planning on?
Sure go for it @saurav2608
Successfully merging a pull request may close this issue.
Code Sample, a copy-pastable example if possible
Problem description
Timestamp.strptime does not support %z. Issue was fixed with
pd.to_datetime
in #19979.Expected Output
The same as
pd.to_datetime(ts, format=fmt)
:Output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.6.8.final.0
python-bits: 64
OS: Linux
OS-release: 4.15.0-43-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: C.UTF-8
LANG: C.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.24.0
pytest: 4.1.1
pip: 18.1
setuptools: 40.6.3
Cython: 0.29.2
numpy: 1.15.4
scipy: None
pyarrow: None
xarray: None
IPython: 7.2.0
sphinx: 1.8.2
patsy: None
dateutil: 2.7.5
pytz: 2018.9
blosc: None
bottleneck: None
tables: 3.4.4
numexpr: 2.6.9
feather: None
matplotlib: 3.0.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml.etree: 4.3.0
bs4: None
html5lib: None
sqlalchemy: 1.2.16
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None
The text was updated successfully, but these errors were encountered: