-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
to_datetime parses dates incorrectly when the format includes '%W' and does not include day of week plus calendar year #16774
Comments
In the docs for datetime.datetime.strptime:
Turns out this is true with to_datetime, too. It'd also be a totally-valid resolution to this issue to include this note in the to_datetime docstring. |
When specifying the day of the week, it indeed seems to work (my locale is set to nl_BE here):
|
I should have phrased the bug more clearly: "to_datetime /only/ parses %W when both day and year are also specified." Ideal behavior would be for a timestamp to be generated for, say, the beginning of the week (as a timestamp is analagously generated for the beginning of a day when no time is specified). Alternate behavior would be for to_datetime to refuse (like datetime.datetime.strptime) to parse such dates but to document this behavior. |
Code Sample, a copy-pastable example if possible
Problem description
to_datetime parses a week XX as 0 for any valid XX. Interestingly, an impossible XX (ex: '70') throws a ValueError as expected.
Expected Output
20
2017-20
Output of
pd.show_versions()
pandas: 0.20.2
pytest: None
pip: 9.0.1
setuptools: 36.0.1
Cython: 0.24.1
numpy: 1.13.0
scipy: 0.18.1
xarray: None
IPython: 6.1.0
sphinx: None
patsy: None
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.0.0
openpyxl: 2.4.0
xlrd: 1.0.0
xlwt: None
xlsxwriter: None
lxml: 3.3.3
bs4: 4.2.1
html5lib: 0.999
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
s3fs: None
pandas_gbq: None
pandas_datareader: None
The text was updated successfully, but these errors were encountered: