-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: inconsistent replace #36444
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: inconsistent replace #36444
Changes from 16 commits
cf5fc6d
3222d60
6a047cf
ff63b40
52ac6f5
f64817b
23bd5ce
0ac9765
473f108
1355628
8b86da4
88c8f7e
b867681
5759673
417bbdb
36e23d1
ada13b6
13ad68e
36a88fe
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 |
---|---|---|
|
@@ -36,6 +36,7 @@ | |
is_datetime64tz_dtype, | ||
is_dtype_equal, | ||
is_extension_array_dtype, | ||
is_float, | ||
is_float_dtype, | ||
is_integer, | ||
is_integer_dtype, | ||
|
@@ -2066,7 +2067,8 @@ def _can_hold_element(self, element: Any) -> bool: | |
and not issubclass(tipo.type, (np.datetime64, np.timedelta64)) | ||
and self.dtype.itemsize >= tipo.itemsize | ||
) | ||
return is_integer(element) | ||
# Will have to be modified in the future see GH 36444 and GH 35376 | ||
return is_integer(element) or (is_float(element) and element.is_integer()) | ||
QuentinN42 marked this conversation as resolved.
Show resolved
Hide resolved
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. @jbrockmendel are you sure you think the patch should be here; this is hit by a lot of paths where this doesn't make any sense. we almost always want to take some sort of action based on return value here if it fails. e.g. why is this not more specific to replace? 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. Also is this simply wrong: [ins] In [3]: is_integer(1.0)
Out[3]: False especially since [ins] In [4]: 1.0.is_integer()
Out[4]: True 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. ahh its doing an equality check under the hood, we are not
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. maybe could replace this entirely with 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. though my concern is still that the purpose of this check is can we hold an integer, not are we a float and can be treated as an integer. though practically it may not make a difference. 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. So I don't realy understand ... 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. Or 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. Longer-term we're going to have to look more carefully about can_hold_element and what we want it to mean. In the short run, for this check to be consistent with the tipo check above it should exclude floats (so my previous suggestion may have been unhelpful, sorry) 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. ok this is fine @QuentinN42 if you can add a comment here would be good |
||
|
||
|
||
class DatetimeLikeBlockMixin: | ||
|
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.
not what I meant.
say something like