-
-
Notifications
You must be signed in to change notification settings - Fork 19.1k
BUG: Dataframe arithmatic operators don't work with Series using fill_value #61828
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
base: main
Are you sure you want to change the base?
Changes from all commits
99ae672
4e77fb7
eb12b34
7e23b65
4617108
bca56fe
7273396
4493e08
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 |
---|---|---|
|
@@ -890,7 +890,14 @@ def _op_method_error_message(self, other, op) -> str: | |
def _evaluate_op_method(self, other, op, arrow_funcs) -> Self: | ||
pa_type = self._pa_array.type | ||
other_original = other | ||
other = self._box_pa(other) | ||
try: | ||
other = self._box_pa(other) | ||
except (ValueError, pa.lib.ArrowTypeError) as err: | ||
# Categorical and Interval dtype raises errors in self._box_pa | ||
# Could be fixed in the future if needed | ||
raise TypeError( | ||
"Incompatible type when converting to PyArrow dtype for operation." | ||
) from err | ||
|
||
if ( | ||
pa.types.is_string(pa_type) | ||
|
@@ -899,6 +906,13 @@ def _evaluate_op_method(self, other, op, arrow_funcs) -> Self: | |
): | ||
if op in [operator.add, roperator.radd]: | ||
sep = pa.scalar("", type=pa_type) | ||
if ( | ||
pa.types.is_string(other.type) | ||
or pa.types.is_large_string(other.type) | ||
or pa.types.is_binary(other.type) | ||
or isna(other).all() | ||
): | ||
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. why is this necessary? 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. We want to limit it to only string + string/null. Allowing other datatypes (eg. TimeDelta, etc) causes weird conversion issues due to being cast directly to string. The last line is there to prevent unwanted conversions from arrays with any null type |
||
other = other.cast(pa_type) | ||
try: | ||
if op is operator.add: | ||
result = pc.binary_join_element_wise(self._pa_array, other, sep) | ||
|
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.
why is this change necessary?
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 found errors when handling Categorical (straight conversion error) and Offsets (No temporal attributes found on object)
This is essentially a wrapper to make it clearer to the user where it went wrong