-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: remove block._coerce_values #27567
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
#27445 is a subset of this |
@@ -51,15 +51,15 @@ def test_indexing_with_datetime_tz(self): | |||
# indexing | |||
result = df.iloc[1] | |||
expected = Series( | |||
[Timestamp("2013-01-02 00:00:00-0500", tz="US/Eastern"), np.nan, np.nan], |
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.
does this not work now (the existing code)?
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.
I think the test is incorrect, and tm.assert_series_equal is getting it wrong.
now = pd.Timestamp.now("US/Eastern")
left = pd.Series([now, pd.NaT, pd.NaT], dtype=object)
right = pd.Series([now, np.nan, np.nan], dtype=object)
tm.assert_series_equal(left, right)
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.
Will open an issue for assert_series_equal
@@ -2512,22 +2468,22 @@ def _try_coerce_args(self, other): | |||
def _try_coerce_result(self, result): | |||
""" reverse of try_coerce_args """ | |||
if isinstance(result, np.ndarray): | |||
if result.dtype.kind in ["i", "f"]: | |||
result = result.astype("M8[ns]") | |||
if result.ndim == 2: |
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.
can you add a comment or 2 here
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.
Done
@@ -1547,14 +1530,13 @@ def quantile(self, qs, interpolation="linear", axis=0): | |||
# We need to operate on i8 values for datetimetz | |||
# but `Block.get_values()` returns an ndarray of objects | |||
# right now. We need an API for "values to do numeric-like ops on" | |||
values = self.values.asi8 | |||
values = self.values.view("M8[ns]") |
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.
we should probably remove .asi8 on Index as I agree its sligthly confusing (I don't think we need deprecation)
thanks |
viable now that we stopped coercing timedelta and datetime to i8
I'd like to clean up DatetimeTZBlock._try_coerce_result before getting this in. Part of that means pushing the handling down to the function being wrapped