コード例 #1
0
ファイル: __init__.py プロジェクト: vinks4u/pandas
    def f(self, other, axis=default_axis, level=None, fill_value=None):

        other = _align_method_FRAME(self, other, axis)

        if isinstance(other, ABCDataFrame):
            # Another DataFrame
            pass_op = op if should_series_dispatch(self, other, op) else na_op
            pass_op = pass_op if not is_logical else op

            left, right = self.align(other,
                                     join="outer",
                                     level=level,
                                     copy=False)
            new_data = left._combine_frame(right, pass_op, fill_value)
            return left._construct_result(new_data)

        elif isinstance(other, ABCSeries):
            # For these values of `axis`, we end up dispatching to Series op,
            # so do not want the masked op.
            pass_op = op if axis in [0, "columns", None] else na_op
            pass_op = pass_op if not is_logical else op
            return _combine_series_frame(self,
                                         other,
                                         pass_op,
                                         fill_value=fill_value,
                                         axis=axis,
                                         level=level)
        else:
            # in this case we always have `np.ndim(other) == 0`
            if fill_value is not None:
                self = self.fillna(fill_value)

            new_data = dispatch_to_series(self, other, op, str_rep)
            return self._construct_result(new_data)
コード例 #2
0
ファイル: __init__.py プロジェクト: vfxavier/pandas
    def f(self, other, axis=default_axis, level=None, fill_value=None):

        self, other = _align_method_FRAME(self,
                                          other,
                                          axis,
                                          flex=True,
                                          level=level)

        if isinstance(other, ABCDataFrame):
            # Another DataFrame
            pass_op = op if should_series_dispatch(self, other, op) else na_op
            pass_op = pass_op if not is_logical else op

            new_data = self._combine_frame(other, pass_op, fill_value)
            return self._construct_result(new_data)

        elif isinstance(other, ABCSeries):
            # For these values of `axis`, we end up dispatching to Series op,
            # so do not want the masked op.
            pass_op = op if axis in [0, "columns", None] else na_op
            pass_op = pass_op if not is_logical else op

            if fill_value is not None:
                raise NotImplementedError(
                    f"fill_value {fill_value} not supported.")

            axis = self._get_axis_number(axis) if axis is not None else 1
            return _combine_series_frame(self, other, pass_op, axis=axis)
        else:
            # in this case we always have `np.ndim(other) == 0`
            if fill_value is not None:
                self = self.fillna(fill_value)

            new_data = dispatch_to_series(self, other, op, str_rep)
            return self._construct_result(new_data)