-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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: Fix inserting of wrong-dtyped NaT, closes #27297 #27311
Conversation
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.
this patch is very awkward. This needs work to make it more fluid.
Might be because it addresses three separate-but-related bugs. Looking at it commit-by-commit might make more sense. I'm happy to make separate PRs if that's easier |
Rebased following #27323. This does for datetime64 Series what that did for timedelta64 Series |
no whatsnew, so doesnt need to be moved |
@@ -2585,8 +2585,11 @@ def setitem(self, indexer, value): | |||
try: | |||
return super().setitem(indexer, value) | |||
except (ValueError, TypeError): | |||
obj_vals = self.values.astype(object) |
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.
do you really need to do this?
if you actually do, then .reshape(1, -1) should just work (or use np.atleast_2d)
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.
Yes, this really is needed.
reshape(1, -1) is what is already 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.
can you give an example that specific needs this 2d reshape?
this just is a completely different pattern than anywhere else. Why for example would the ObjectBlock construct not simply reshape (if needed); it already knows the dim & the values shape?
@@ -2585,8 +2585,11 @@ def setitem(self, indexer, value): | |||
try: | |||
return super().setitem(indexer, value) | |||
except (ValueError, TypeError): | |||
obj_vals = self.values.astype(object) |
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 give an example that specific needs this 2d reshape?
this just is a completely different pattern than anywhere else. Why for example would the ObjectBlock construct not simply reshape (if needed); it already knows the dim & the values shape?
Because the Block constructor calls self._validate_ndim to check that it got the expected shape. reshaping is done earlier. |
is this not exactly what |
It is, but block_shape gets called before the constructor. But apparently it isnt necessary. Just ran the tests with this reshape disabled and its fine now. Will remove. |
removed+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.
hmm I think this need s a whatsnew note, would do on 1.0
if not should_cast: | ||
expected = expected.astype(object) | ||
|
||
ser = base.copy(deep=True) |
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.
do these need to be deep? (no big deal though)
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.
yes
whatsnew added + green |
thanks @jbrockmendel |
It looks like this is causing a bunch of CI failures. cc @jreback @TomAugspurger |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
Needs tests for PeriodDType case. The tests are probably not in the ideal place, how to move/parametrize them depends on what axis we want to sort them along (i.e. all Series indexing tests together or all timedelta-insertion tests together)