A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/pandas-dev/pandas/issues/50308 below:

misleading message when using to_datetime with format='%V %a' · Issue #50308 · pandas-dev/pandas · GitHub

In [2]: to_datetime('20 Monday', format='%V %A')
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[2], line 1
----> 1 to_datetime('20 Monday', format='%V %A')

File ~/pandas-dev/pandas/core/tools/datetimes.py:1100, in to_datetime(arg, errors, dayfirst, yearfirst, utc, format, exact, unit, infer_datetime_format, origin, cache)
   1098         result = convert_listlike(argc, format)
   1099 else:
-> 1100     result = convert_listlike(np.array([arg]), format)[0]
   1101     if isinstance(arg, bool) and isinstance(result, np.bool_):
   1102         result = bool(result)  # TODO: avoid this kludge.

File ~/pandas-dev/pandas/core/tools/datetimes.py:442, in _convert_listlike_datetimes(arg, format, name, utc, unit, errors, dayfirst, yearfirst, exact)
    439 require_iso8601 = format is not None and format_is_iso(format)
    441 if format is not None and not require_iso8601:
--> 442     return _to_datetime_with_format(
    443         arg,
    444         orig_arg,
    445         name,
    446         utc,
    447         format,
    448         exact,
    449         errors,
    450     )
    452 result, tz_parsed = objects_to_datetime64ns(
    453     arg,
    454     dayfirst=dayfirst,
   (...)
    461     exact=exact,
    462 )
    464 if tz_parsed is not None:
    465     # We can take a shortcut since the datetime64 numpy array
    466     # is in UTC

File ~/pandas-dev/pandas/core/tools/datetimes.py:543, in _to_datetime_with_format(arg, orig_arg, name, utc, fmt, exact, errors)
    540         return _box_as_indexlike(result, utc=utc, name=name)
    542 # fallback
--> 543 res = _array_strptime_with_fallback(arg, name, utc, fmt, exact, errors)
    544 return res

File ~/pandas-dev/pandas/core/tools/datetimes.py:485, in _array_strptime_with_fallback(arg, name, utc, fmt, exact, errors)
    481 """
    482 Call array_strptime, with fallback behavior depending on 'errors'.
    483 """
    484 try:
--> 485     result, timezones = array_strptime(
    486         arg, fmt, exact=exact, errors=errors, utc=utc
    487     )
    488 except OutOfBoundsDatetime:
    489     if errors == "raise":

File ~/pandas-dev/pandas/_libs/tslibs/strptime.pyx:347, in pandas._libs.tslibs.strptime.array_strptime()
    345 week_of_year = int(found_dict[group_key])
    346 if group_key == "U":
--> 347     # U starts week on Sunday.
    348     week_of_year_start = 6
    349 else:

ValueError: ISO week directive '%V' is incompatible with the year directive '%Y'. Use the ISO year '%G' instead.
ValueError: ISO year directive '%V' must be used with the ISO week directive '%G' and a weekday directive '%A', '%a', '%w', or '%u'.

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4