-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: Fix inserting of wrong-dtyped NaT, closes #27297 #27311
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
Changes from 5 commits
ee426ab
511650c
3c916c1
d39503d
b047cce
7399ef0
5e0004c
7721404
217ce63
bca4e2a
d32c1bf
715002f
c001aca
49eec2e
96bda53
42183e9
7c260d5
b035e4e
fbc1836
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2295,7 +2295,8 @@ def _try_coerce_args(self, other): | |
------- | ||
base-type other | ||
""" | ||
if is_null_datetimelike(other): | ||
if is_null_datetimelike(other) and not isinstance(other, np.timedelta64): | ||
# exclude np.timedelta64("NaT") | ||
other = tslibs.iNaT | ||
elif isinstance(other, (datetime, np.datetime64, date)): | ||
other = self._box_func(other) | ||
|
@@ -2485,7 +2486,8 @@ def _try_coerce_args(self, other): | |
# add the tz back | ||
other = self._holder(other, dtype=self.dtype) | ||
|
||
elif is_null_datetimelike(other): | ||
if is_null_datetimelike(other) and not isinstance(other, np.timedelta64): | ||
# exclude np.timedelta64("NaT") | ||
other = tslibs.iNaT | ||
elif isinstance(other, self._holder): | ||
if other.tz != self.values.tz: | ||
|
@@ -2589,8 +2591,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 commentThe 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 commentThe 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 commentThe 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? |
||
if self.ndim == 2 and obj_vals.ndim == 1: | ||
obj_vals = obj_vals.reshape(1, -1) | ||
newb = make_block( | ||
self.values.astype(object), placement=self.mgr_locs, klass=ObjectBlock | ||
obj_vals, placement=self.mgr_locs, klass=ObjectBlock, ndim=self.ndim | ||
) | ||
return newb.setitem(indexer, value) | ||
|
||
|
@@ -2665,7 +2670,8 @@ def _try_coerce_args(self, other): | |
base-type other | ||
""" | ||
|
||
if is_null_datetimelike(other): | ||
if is_null_datetimelike(other) and not isinstance(other, np.datetime64): | ||
# exclude np.datetime64("NaT") | ||
other = tslibs.iNaT | ||
elif isinstance(other, (timedelta, np.timedelta64)): | ||
other = Timedelta(other).value | ||
|
Uh oh!
There was an error while loading. Please reload this page.