Skip to content

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

Closed
wants to merge 37 commits into from

Conversation

shubham11941140
Copy link
Contributor

@shubham11941140 shubham11941140 commented Oct 17, 2021

Converted values of xarray.DataArray to numpy.ndarray to solve the problem.

@pep8speaks
Copy link

pep8speaks commented Oct 17, 2021

Hello @shubham11941140! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 2656:5: E265 block comment should start with '# '
Line 2661:16: E128 continuation line under-indented for visual indent
Line 2662:16: E128 continuation line under-indented for visual indent
Line 2663:15: E128 continuation line under-indented for visual indent

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
Copy link
Contributor

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

Copy link
Contributor Author

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():
Copy link
Contributor

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

@jreback
Copy link
Contributor

jreback commented Oct 18, 2021

closing in favor of #44074

@jreback jreback closed this Oct 18, 2021
@shubham11941140 shubham11941140 deleted the b2 branch October 18, 2021 02:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: to_datetime with xarray DataArray and specifie unit errors
3 participants