-
-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
Conversation
@jreback just rebased with a fix for the unused import in groupby.py |
@jreback gentle ping; in addition to being a bug this is a blocker for further simplification in blocks |
merge master on this |
rebased+green |
rebased+green |
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.
looks good some comments
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) |
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 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"]) |
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.
could use the timezone fixtures, but nbd
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.
?
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.
sure
pandas/core/internals/blocks.py
Outdated
cond = cond.T | ||
|
||
if not hasattr(cond, "shape"): | ||
raise ValueError("where must have a condition that is ndarray like") |
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.
is this actually hit? shouldn't this be an assertion (i know this is friendler of course), but still.
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.
actually you explicity check this on L1347 no?
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.
good catch, will remove
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.
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)]) |
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 pass thru 2-D pandas arrays?
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.
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"]) |
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.
?
let's rebase one more time after your _where change was merged; ping on green |
ping |
* ENH: support 2D in DatetimeArray._from_sequence * BUG: Series.where casting dt64 to int64 * whatsnew * move whatsnew * use fixture, remove unnecessary check
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
This sits on top of #38021