-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
Fix period range #5393
Fix period range #5393
Conversation
Thanks for the fix! Looks good to me though the new unit test is currently failing with:
Looks like you just need to use Happy to merge once the tests are green. |
After thinking about it, I think the correct fix is in Before my last commit, it would return TypeError Traceback (most recent call last)
Input In [3], in <cell line: 1>()
----> 1 pd.to_datetime(pd.Period("1990", freq="M"))
File ~/miniconda3/envs/holoviz/lib/python3.9/site-packages/pandas/core/tools/datetimes.py:1078, in to_datetime(arg, errors, dayfirst, yearfirst, utc, format, exact, unit, infer_datetime_format, origin, cache)
1076 result = convert_listlike(arg, format)
1077 else:
-> 1078 result = convert_listlike(np.array([arg]), format)[0]
1080 # error: Incompatible return value type (got "Union[Timestamp, NaTType,
1081 # Series, Index]", expected "Union[DatetimeIndex, Series, float, str,
1082 # NaTType, None]")
1083 return result
File ~/miniconda3/envs/holoviz/lib/python3.9/site-packages/pandas/core/tools/datetimes.py:402, in _convert_listlike_datetimes(arg, format, name, tz, unit, errors, infer_datetime_format, dayfirst, yearfirst, exact)
400 assert format is None or infer_datetime_format
401 utc = tz == "utc"
--> 402 result, tz_parsed = objects_to_datetime64ns(
403 arg,
404 dayfirst=dayfirst,
405 yearfirst=yearfirst,
406 utc=utc,
407 errors=errors,
408 require_iso8601=require_iso8601,
409 allow_object=True,
410 )
412 if tz_parsed is not None:
413 # We can take a shortcut since the datetime64 numpy array
414 # is in UTC
415 dta = DatetimeArray(result, dtype=tz_to_dtype(tz_parsed))
File ~/miniconda3/envs/holoviz/lib/python3.9/site-packages/pandas/core/arrays/datetimes.py:2224, in objects_to_datetime64ns(data, dayfirst, yearfirst, utc, errors, require_iso8601, allow_object, allow_mixed)
2222 order: Literal["F", "C"] = "F" if flags.f_contiguous else "C"
2223 try:
-> 2224 result, tz_parsed = tslib.array_to_datetime(
2225 data.ravel("K"),
2226 errors=errors,
2227 utc=utc,
2228 dayfirst=dayfirst,
2229 yearfirst=yearfirst,
2230 require_iso8601=require_iso8601,
2231 allow_mixed=allow_mixed,
2232 )
2233 result = result.reshape(data.shape, order=order)
2234 except ValueError as err:
File ~/miniconda3/envs/holoviz/lib/python3.9/site-packages/pandas/_libs/tslib.pyx:381, in pandas._libs.tslib.array_to_datetime()
File ~/miniconda3/envs/holoviz/lib/python3.9/site-packages/pandas/_libs/tslib.pyx:613, in pandas._libs.tslib.array_to_datetime()
File ~/miniconda3/envs/holoviz/lib/python3.9/site-packages/pandas/_libs/tslib.pyx:755, in pandas._libs.tslib._array_to_datetime_object()
File ~/miniconda3/envs/holoviz/lib/python3.9/site-packages/pandas/_libs/tslib.pyx:586, in pandas._libs.tslib.array_to_datetime()
TypeError: <class 'pandas._libs.tslibs.period.Period'> is not convertible to datetime |
Codecov Report
@@ Coverage Diff @@
## master #5393 +/- ##
=======================================
Coverage 88.07% 88.07%
=======================================
Files 301 301
Lines 61969 61972 +3
=======================================
+ Hits 54579 54582 +3
Misses 7390 7390
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Looks good to me! |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Fixes #5392