Skip to content
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

BUG: Series.where casting dt64 to int64 #38073

Merged
merged 18 commits into from
Dec 29, 2020

Conversation

jbrockmendel
Copy link
Member

This sits on top of #38021

@jreback jreback added Indexing Related to indexing on series/frames, not to indexes themselves Datetime Datetime data dtype labels Nov 26, 2020
@jbrockmendel
Copy link
Member Author

@jreback just rebased with a fix for the unused import in groupby.py

@jbrockmendel
Copy link
Member Author

@jreback gentle ping; in addition to being a bug this is a blocker for further simplification in blocks

@jreback
Copy link
Contributor

jreback commented Dec 17, 2020

merge master on this

@jbrockmendel
Copy link
Member Author

rebased+green

@jbrockmendel
Copy link
Member Author

rebased+green

Copy link
Contributor

@jreback jreback left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good some comments

pandas/core/internals/blocks.py Show resolved Hide resolved
self, other, cond, errors="raise", try_cast: bool = False, axis: int = 0
) -> List["Block"]:
# TODO(EA2D): reshape unnecessary with 2D EAs
arr = self.array_values().reshape(self.shape)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can almost use your ravel_compat decorator

@@ -464,3 +464,34 @@ def test_where_categorical(klass):
df = klass(["A", "A", "B", "B", "C"], dtype="category")
res = df.where(df != "C")
tm.assert_equal(exp, res)


@pytest.mark.parametrize("tz", [None, "US/Pacific"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could use the timezone fixtures, but nbd

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure

@jreback jreback added this to the 1.3 milestone Dec 28, 2020
cond = cond.T

if not hasattr(cond, "shape"):
raise ValueError("where must have a condition that is ndarray like")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this actually hit? shouldn't this be an assertion (i know this is friendler of course), but still.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually you explicity check this on L1347 no?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch, will remove

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated + green

@@ -278,7 +278,7 @@ def test_array_inference_fails(data):
tm.assert_extension_array_equal(result, expected)


@pytest.mark.parametrize("data", [np.array([[1, 2], [3, 4]]), [[1, 2], [3, 4]]])
@pytest.mark.parametrize("data", [np.array(0)])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we pass thru 2-D pandas arrays?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DTA/TDA._validate_listlike calls pd.array on possibly-2D inputs, which go through PandasArray

@@ -464,3 +464,34 @@ def test_where_categorical(klass):
df = klass(["A", "A", "B", "B", "C"], dtype="category")
res = df.where(df != "C")
tm.assert_equal(exp, res)


@pytest.mark.parametrize("tz", [None, "US/Pacific"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

@jreback
Copy link
Contributor

jreback commented Dec 29, 2020

let's rebase one more time after your _where change was merged; ping on green

@jbrockmendel
Copy link
Member Author

ping

@jreback jreback merged commit db1be4d into pandas-dev:master Dec 29, 2020
@jbrockmendel jbrockmendel deleted the bug-series-where branch December 29, 2020 18:13
luckyvs1 pushed a commit to luckyvs1/pandas that referenced this pull request Jan 20, 2021
* ENH: support 2D in DatetimeArray._from_sequence

* BUG: Series.where casting dt64 to int64

* whatsnew

* move whatsnew

* use fixture, remove unnecessary check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Index.where vs Series.where mismatch
2 participants