-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: enforce deprecation of interpolate
with object dtype
#57820
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
fb51b69
b2ee587
3ae7d75
cb2179f
ea76776
823e467
e3c56a8
05f805c
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 |
---|---|---|
|
@@ -7845,17 +7845,13 @@ def interpolate( | |
obj, should_transpose = self, False | ||
else: | ||
obj, should_transpose = (self.T, True) if axis == 1 else (self, False) | ||
if np.any(obj.dtypes == object): | ||
# GH#53631 | ||
if not (obj.ndim == 2 and np.all(obj.dtypes == object)): | ||
# don't warn in cases that already raise | ||
warnings.warn( | ||
f"{type(self).__name__}.interpolate with object dtype is " | ||
"deprecated and will raise in a future version. Call " | ||
"obj.infer_objects(copy=False) before interpolating instead.", | ||
FutureWarning, | ||
stacklevel=find_stack_level(), | ||
) | ||
# GH#53631 | ||
if np.any(obj.dtypes == object) and ( | ||
obj.ndim == 1 or not np.all(obj.dtypes == object) | ||
): | ||
raise TypeError( | ||
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. I'd suggest doing this check inside Block.interpolate 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. there's a TODO(3.0) comment related to this inside Block.interpolate 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. thank you, I found the comment. In #58083 I moved raising TypeError from I think maybe it's better to change the error message from |
||
f"{type(self).__name__} cannot interpolate with object dtype." | ||
) | ||
|
||
if method in fillna_methods and "fill_value" in kwargs: | ||
raise ValueError( | ||
|
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 like part of this is already handled below (
if obj.ndim == 2 and np.all(obj.dtypes == object)
).In instead nearby that check could you add a
if obj.ndim == 1 and obj.dtype == 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.
Thank you. To avoid duplicate checks I changed blocks of
if
statements as you suggested.