Skip to content

WIP: ENH implement fill_value for _combine_series_frame #13488 #23126

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions pandas/core/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -1750,29 +1750,40 @@ def _combine_series_frame(self, other, func, fill_value=None, axis=None,
-------
result : DataFrame
"""

def wrap(res):
if fill_value is not None:
return res.fillna(fill_value)
else:
return res

if fill_value is not None:
raise NotImplementedError("fill_value {fill} not supported."
.format(fill=fill_value))
if not is_scalar(fill_value):
raise NotImplementedError("fill_value is \
only supported for scalar values.")

self = self.fillna(fill_value)
other = other.fillna(fill_value)

if axis is not None:
axis = self._get_axis_number(axis)
if axis == 0:
return self._combine_match_index(other, func, level=level)
return wrap(self._combine_match_index(other, func, level=level))
else:
return self._combine_match_columns(other, func, level=level,
try_cast=try_cast)
return wrap(self._combine_match_columns(other, func, level=level,
try_cast=try_cast))
else:
if not len(other):
return self * np.nan
return wrap(self * np.nan)

if not len(self):
# Ambiguous case, use _series so works with DataFrame
return self._constructor(data=self._series, index=self.index,
columns=self.columns)

# default axis is columns
return self._combine_match_columns(other, func, level=level,
try_cast=try_cast)
return wrap(self._combine_match_columns(other, func, level=level,
try_cast=try_cast))


def _align_method_FRAME(left, right, axis):
Expand Down