Skip to content

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

Merged
merged 30 commits into from
Jul 26, 2019
Merged

CLN: remove block._coerce_values #27567

merged 30 commits into from
Jul 26, 2019

Conversation

jbrockmendel
Copy link
Member

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

@jbrockmendel
Copy link
Member Author

#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],
Copy link
Contributor

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)?

Copy link
Member Author

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)

Copy link
Member Author

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

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

Copy link
Member Author

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]")
Copy link
Contributor

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)

@jreback jreback added the Clean label Jul 26, 2019
@jreback jreback added this to the 1.0 milestone Jul 26, 2019
@jreback jreback merged commit c00d683 into pandas-dev:master Jul 26, 2019
@jreback
Copy link
Contributor

jreback commented Jul 26, 2019

thanks

@jbrockmendel jbrockmendel deleted the inat3 branch July 26, 2019 21:44
quintusdias pushed a commit to quintusdias/pandas_dev that referenced this pull request Aug 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants