-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: to_datetime with xarray DataArray and specifie unit errors #44073
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
Conversation
Hello @shubham11941140! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:
Comment last updated at 2021-10-17 19:46:06 UTC |
@@ -525,7 +525,13 @@ def _to_datetime_with_unit(arg, unit, name, tz, errors: str) -> Index: | |||
arr = arg.astype(f"datetime64[{unit}]") | |||
tz_parsed = None | |||
else: | |||
arr, tz_parsed = tslib.array_with_unit_to_datetime(arg, unit, errors=errors) | |||
import xarray |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls don't import xarray like this
it's not a dependency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do I do it? Should I write it on top?
@@ -2650,3 +2650,15 @@ def test_to_datetime_monotonic_increasing_index(cache): | |||
result = to_datetime(times.iloc[:, 0], cache=cache) | |||
expected = times.iloc[:, 0] | |||
tm.assert_series_equal(result, expected) | |||
|
|||
def test_xarray_DataArray(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you will need to skip if xarray is not installed
closing in favor of #44074 |
Converted values of xarray.DataArray to numpy.ndarray to solve the problem.