8000 ERR: Raise ValueError when week is passed in to_datetime format witho… by reidy-p · Pull Request #17819 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

ERR: Raise ValueError when week is passed in to_datetime format witho… #17819

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

Merged
merged 3 commits into from
Oct 14, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8000 Prev Previous commit
Moving check to strptime.pyx
  • Loading branch information
reidy-p committed Oct 14, 2017
commit c2c8810f4c1ed9327285249552ee72830571a67c
10 changes: 10 additions & 0 deletions pandas/_libs/tslibs/strptime.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,16 @@ def array_strptime(ndarray[object] values, object fmt,

assert is_raise or is_ignore or is_coerce

if fmt is not None:
if '%W' in fmt or '%U' in fmt:
if '%Y' not in fmt and '%y' not in fmt:
raise ValueError("Cannot use '%W' or '%U' without "
"day and year")
if ('%A' not in fmt and '%a' not in fmt and '%w' not
in fmt):
raise ValueError("Cannot use '%W' or '%U' without "
"day and year")

global _TimeRE_cache, _regex_cache
with _cache_lock:
if _getlang() != _TimeRE_cache.locale_time.lang:
Expand Down
10 changes: 0 additions & 10 deletions pandas/core/tools/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,16 +254,6 @@ def _convert_listlike(arg, box, format, name=None, tz=tz):
require_iso8601 = not infer_datetime_format
format = None

if format is not None:
if '%W' in format or '%U' in format:
if '%Y' not in format and '%y' not in format:
raise ValueError("Cannot use '%W' or '%U' without "
"day and year")
if ('%A' not in format and '%a' not in format and '%w' not
in format):
raise ValueError("Cannot use '%W' or '%U' without "
"day and year")

try:
result = None

Expand Down
0