-
Notifications
You must be signed in to change notification settings - Fork 43
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
fix: dataframe fillna with scalar. #1132
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.
LGTM overall with a nit question:
If I understand correctly, before this Pull Request, using fillna
with a string scalar would result in a NotImplemented
error. If that's the case, perhaps the title should start with feat:
instead of fix:
?
@@ -734,7 +734,7 @@ def _apply_binop( | |||
how: str = "outer", | |||
reverse: bool = False, | |||
): | |||
if isinstance(other, (float, int, bool)): |
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.
I feel like just adding another type here is a narrow fix - what we really want to do is determine - is this type interpretable as a supported scalar. This could include datatime objects, decimal, etc as well. We should probably have a single definition of this somewhere
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.
Added a LOCAL_SCALAR_TYPES constant, all types are from infer_literal_type function, should be supported.
bigframes/dataframe.py
Outdated
@@ -752,7 +752,7 @@ def _apply_binop( | |||
) | |||
|
|||
def _apply_scalar_binop( | |||
self, other: float | int, op: ops.BinaryOp, reverse: bool = False | |||
self, other: float | int | bool | str, op: ops.BinaryOp, reverse: bool = False |
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.
Should we use bigframes.dtypes.LOCAL_SCALAR_TYPES
here too?
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, added a new constant for annotation.
datetime.date, | ||
datetime.time, | ||
] | ||
LOCAL_SCALAR_TYPES = typing.get_args(LOCAL_SCALAR_TYPE) |
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.
I have a feeling we will just give up at a certain point as we add more types
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #<issue_number_goes_here> 🦕