diff --git a/bigframes/dataframe.py b/bigframes/dataframe.py index 32f5a36f79..2deef95277 100644 --- a/bigframes/dataframe.py +++ b/bigframes/dataframe.py @@ -17,6 +17,7 @@ from __future__ import annotations import datetime +import inspect import re import sys import textwrap @@ -314,6 +315,8 @@ def __len__(self): rows, _ = self.shape return rows + __len__.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.__len__) + def __iter__(self): return iter(self.columns) @@ -466,7 +469,6 @@ def __getitem__( bigframes.series.Series, ], ): # No return type annotations (like pandas) as type cannot always be determined statically - """Gets the specified column(s) from the DataFrame.""" # NOTE: This implements the operations described in # https://pandas.pydata.org/docs/getting_started/intro_tutorials/03_subset_data.html @@ -498,6 +500,8 @@ def __getitem__( return DataFrame(self._block.select_columns(selected_ids)) + __getitem__.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.__getitem__) + def _getitem_label(self, key: blocks.Label): col_ids = self._block.cols_matching_label(key) if len(col_ids) == 0: @@ -642,14 +646,11 @@ def _repr_html_(self) -> str: return html_string def __setitem__(self, key: str, value: SingleItemValue): - """Modify or insert a column into the DataFrame. - - Note: This does **not** modify the original table the DataFrame was - derived from. - """ df = self._assign_single_item(key, value) self._set_block(df._get_block()) + __setitem__.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.__setitem__) + def _apply_binop( self, other: float | int | bigframes.series.Series | DataFrame, @@ -838,32 +839,50 @@ def _apply_dataframe_binop( def eq(self, other: typing.Any, axis: str | int = "columns") -> DataFrame: return self._apply_binop(other, ops.eq_op, axis=axis) + def __eq__(self, other) -> DataFrame: # type: ignore + return self.eq(other) + + __eq__.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.__eq__) + def ne(self, other: typing.Any, axis: str | int = "columns") -> DataFrame: return self._apply_binop(other, ops.ne_op, axis=axis) - __eq__ = eq # type: ignore + def __ne__(self, other) -> DataFrame: # type: ignore + return self.ne(other) - __ne__ = ne # type: ignore + __ne__.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.__ne__) def le(self, other: typing.Any, axis: str | int = "columns") -> DataFrame: return self._apply_binop(other, ops.le_op, axis=axis) + def __le__(self, other) -> DataFrame: + return self.le(other) + + __le__.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.__le__) + def lt(self, other: typing.Any, axis: str | int = "columns") -> DataFrame: return self._apply_binop(other, ops.lt_op, axis=axis) + def __lt__(self, other) -> DataFrame: + return self.lt(other) + + __lt__.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.__lt__) + def ge(self, other: typing.Any, axis: str | int = "columns") -> DataFrame: return self._apply_binop(other, ops.ge_op, axis=axis) - def gt(self, other: typing.Any, axis: str | int = "columns") -> DataFrame: - return self._apply_binop(other, ops.gt_op, axis=axis) + def __ge__(self, other) -> DataFrame: + return self.ge(other) - __lt__ = lt + __ge__.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.__ge__) - __le__ = le + def gt(self, other: typing.Any, axis: str | int = "columns") -> DataFrame: + return self._apply_binop(other, ops.gt_op, axis=axis) - __gt__ = gt + def __gt__(self, other) -> DataFrame: + return self.gt(other) - __ge__ = ge + __gt__.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.__gt__) def add( self, @@ -874,7 +893,21 @@ def add( # TODO(swast): Support level parameter with MultiIndex. return self._apply_binop(other, ops.add_op, axis=axis) - __radd__ = __add__ = radd = add + def radd( + self, + other: float | int | bigframes.series.Series | DataFrame, + axis: str | int = "columns", + ) -> DataFrame: + # TODO(swast): Support fill_value parameter. + # TODO(swast): Support level parameter with MultiIndex. + return self.add(other, axis=axis) + + def __add__(self, other) -> DataFrame: + return self.add(other) + + __add__.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.__add__) + + __radd__ = __add__ def sub( self, @@ -883,7 +916,13 @@ def sub( ) -> DataFrame: return self._apply_binop(other, ops.sub_op, axis=axis) - __sub__ = subtract = sub + subtract = sub + subtract.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.sub) + + def __sub__(self, other): + return self.sub(other) + + __sub__.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.__sub__) def rsub( self, @@ -892,7 +931,10 @@ def rsub( ) -> DataFrame: return self._apply_binop(other, ops.sub_op, axis=axis, reverse=True) - __rsub__ = rsub + def __rsub__(self, other): + return self.rsub(other) + + __rsub__.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.__rsub__) def mul( self, @@ -901,7 +943,25 @@ def mul( ) -> DataFrame: return self._apply_binop(other, ops.mul_op, axis=axis) - __rmul__ = __mul__ = rmul = multiply = mul + multiply = mul + multiply.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.mul) + + def __mul__(self, other): + return self.mul(other) + + __mul__.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.__mul__) + + def rmul( + self, + other: float | int | bigframes.series.Series | DataFrame, + axis: str | int = "columns", + ) -> DataFrame: + return self.mul(other, axis=axis) + + def __rmul__(self, other): + return self.rmul(other) + + __rmul__.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.__rmul__) def truediv( self, @@ -910,7 +970,13 @@ def truediv( ) -> DataFrame: return self._apply_binop(other, ops.div_op, axis=axis) - div = divide = __truediv__ = truediv + truediv.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.truediv) + div = divide = truediv + + def __truediv__(self, other): + return self.truediv(other) + + __truediv__.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.__truediv__) def rtruediv( self, @@ -919,7 +985,13 @@ def rtruediv( ) -> DataFrame: return self._apply_binop(other, ops.div_op, axis=axis, reverse=True) - __rtruediv__ = rdiv = rtruediv + rdiv = rtruediv + rdiv.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.rtruediv) + + def __rtruediv__(self, other): + return self.rtruediv(other) + + __rtruediv__.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.__rtruediv__) def floordiv( self, @@ -928,7 +1000,10 @@ def floordiv( ) -> DataFrame: return self._apply_binop(other, ops.floordiv_op, axis=axis) - __floordiv__ = floordiv + def __floordiv__(self, other): + return self.floordiv(other) + + __floordiv__.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.__floordiv__) def rfloordiv( self, @@ -937,31 +1012,48 @@ def rfloordiv( ) -> DataFrame: return self._apply_binop(other, ops.floordiv_op, axis=axis, reverse=True) - __rfloordiv__ = rfloordiv + def __rfloordiv__(self, other): + return self.rfloordiv(other) + + __rfloordiv__.__doc__ = inspect.getdoc( + vendored_pandas_frame.DataFrame.__rfloordiv__ + ) def mod(self, other: int | bigframes.series.Series | DataFrame, axis: str | int = "columns") -> DataFrame: # type: ignore return self._apply_binop(other, ops.mod_op, axis=axis) + def __mod__(self, other): + return self.mod(other) + + __mod__.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.__mod__) + def rmod(self, other: int | bigframes.series.Series | DataFrame, axis: str | int = "columns") -> DataFrame: # type: ignore return self._apply_binop(other, ops.mod_op, axis=axis, reverse=True) - __mod__ = mod + def __rmod__(self, other): + return self.rmod(other) - __rmod__ = rmod + __rmod__.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.__rmod__) def pow( self, other: int | bigframes.series.Series, axis: str | int = "columns" ) -> DataFrame: return self._apply_binop(other, ops.pow_op, axis=axis) + def __pow__(self, other): + return self.pow(other) + + __pow__.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.__pow__) + def rpow( self, other: int | bigframes.series.Series, axis: str | int = "columns" ) -> DataFrame: return self._apply_binop(other, ops.pow_op, axis=axis, reverse=True) - __pow__ = pow + def __rpow__(self, other): + return self.rpow(other) - __rpow__ = rpow + __rpow__.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.__rpow__) def align( self, @@ -1971,6 +2063,7 @@ def prod( return bigframes.series.Series(block.select_column("values")) product = prod + product.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.prod) def count(self, *, numeric_only: bool = False) -> bigframes.series.Series: if not numeric_only: @@ -2010,6 +2103,7 @@ def agg( ) aggregate = agg + aggregate.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.agg) def idxmin(self) -> bigframes.series.Series: return bigframes.series.Series(block_ops.idxmin(self._block)) @@ -2083,6 +2177,7 @@ def kurt(self, *, numeric_only: bool = False): return bigframes.series.Series(result_block) kurtosis = kurt + kurtosis.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.kurt) def _pivot( self, @@ -2542,11 +2637,13 @@ def isna(self) -> DataFrame: return self._apply_unary_op(ops.isnull_op) isnull = isna + isnull.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.isna) def notna(self) -> DataFrame: return self._apply_unary_op(ops.notnull_op) notnull = notna + notnull.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.notna) def cumsum(self): is_numeric_types = [ @@ -2860,7 +2957,10 @@ def to_numpy( ) -> numpy.ndarray: return self.to_pandas().to_numpy(dtype, copy, na_value, **kwargs) - __array__ = to_numpy + def __array__(self, dtype=None) -> numpy.ndarray: + return self.to_numpy(dtype=dtype) + + __array__.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.__array__) def to_parquet( self, @@ -3227,6 +3327,7 @@ def first_valid_index(self): return applymap = map + applymap.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.map) def _slice( self, @@ -3367,4 +3468,7 @@ def get_right_id(id): def plot(self): return plotting.PlotAccessor(self) - __matmul__ = dot + def __matmul__(self, other) -> DataFrame: + return self.dot(other) + + __matmul__.__doc__ = inspect.getdoc(vendored_pandas_frame.DataFrame.__matmul__) diff --git a/bigframes/series.py b/bigframes/series.py index f11511f969..2f9123f9a3 100644 --- a/bigframes/series.py +++ b/bigframes/series.py @@ -17,6 +17,7 @@ from __future__ import annotations import functools +import inspect import itertools import numbers import os @@ -180,6 +181,8 @@ def _set_internal_query_job(self, query_job: bigquery.QueryJob): def __len__(self): return self.shape[0] + __len__.__doc__ = inspect.getdoc(vendored_pandas_series.Series.__len__) + def __iter__(self) -> typing.Iterator: self._optimize_query_complexity() return itertools.chain.from_iterable( @@ -423,6 +426,7 @@ def ffill(self, *, limit: typing.Optional[int] = None) -> Series: return self._apply_window_op(agg_ops.LastNonNullOp(), window) pad = ffill + pad.__doc__ = inspect.getdoc(vendored_pandas_series.Series.ffill) def bfill(self, *, limit: typing.Optional[int] = None) -> Series: window = bigframes.core.window_spec.WindowSpec(preceding=0, following=limit) @@ -609,28 +613,38 @@ def isna(self) -> "Series": return self._apply_unary_op(ops.isnull_op) isnull = isna + isnull.__doc__ = inspect.getdoc(vendored_pandas_series.Series.isna) def notna(self) -> "Series": return self._apply_unary_op(ops.notnull_op) notnull = notna + notnull.__doc__ = inspect.getdoc(vendored_pandas_series.Series.notna) def __and__(self, other: bool | int | Series) -> Series: return self._apply_binary_op(other, ops.and_op) + __and__.__doc__ = inspect.getdoc(vendored_pandas_series.Series.__and__) + __rand__ = __and__ def __or__(self, other: bool | int | Series) -> Series: return self._apply_binary_op(other, ops.or_op) + __or__.__doc__ = inspect.getdoc(vendored_pandas_series.Series.__or__) + __ror__ = __or__ def __add__(self, other: float | int | Series) -> Series: return self.add(other) + __add__.__doc__ = inspect.getdoc(vendored_pandas_series.Series.__add__) + def __radd__(self, other: float | int | Series) -> Series: return self.radd(other) + __radd__.__doc__ = inspect.getdoc(vendored_pandas_series.Series.__radd__) + def add(self, other: float | int | Series) -> Series: return self._apply_binary_op(other, ops.add_op) @@ -640,9 +654,13 @@ def radd(self, other: float | int | Series) -> Series: def __sub__(self, other: float | int | Series) -> Series: return self.sub(other) + __sub__.__doc__ = inspect.getdoc(vendored_pandas_series.Series.__sub__) + def __rsub__(self, other: float | int | Series) -> Series: return self.rsub(other) + __rsub__.__doc__ = inspect.getdoc(vendored_pandas_series.Series.__rsub__) + def sub(self, other: float | int | Series) -> Series: return self._apply_binary_op(other, ops.sub_op) @@ -650,13 +668,18 @@ def rsub(self, other: float | int | Series) -> Series: return self._apply_binary_op(other, ops.sub_op, reverse=True) subtract = sub + subtract.__doc__ = inspect.getdoc(vendored_pandas_series.Series.sub) def __mul__(self, other: float | int | Series) -> Series: return self.mul(other) + __mul__.__doc__ = inspect.getdoc(vendored_pandas_series.Series.__mul__) + def __rmul__(self, other: float | int | Series) -> Series: return self.rmul(other) + __rmul__.__doc__ = inspect.getdoc(vendored_pandas_series.Series.__rmul__) + def mul(self, other: float | int | Series) -> Series: return self._apply_binary_op(other, ops.mul_op) @@ -664,31 +687,40 @@ def rmul(self, other: float | int | Series) -> Series: return self._apply_binary_op(other, ops.mul_op, reverse=True) multiply = mul + multiply.__doc__ = inspect.getdoc(vendored_pandas_series.Series.mul) def __truediv__(self, other: float | int | Series) -> Series: return self.truediv(other) + __truediv__.__doc__ = inspect.getdoc(vendored_pandas_series.Series.__truediv__) + def __rtruediv__(self, other: float | int | Series) -> Series: return self.rtruediv(other) + __rtruediv__.__doc__ = inspect.getdoc(vendored_pandas_series.Series.__rtruediv__) + def truediv(self, other: float | int | Series) -> Series: return self._apply_binary_op(other, ops.div_op) def rtruediv(self, other: float | int | Series) -> Series: return self._apply_binary_op(other, ops.div_op, reverse=True) - div = truediv - - divide = truediv + truediv.__doc__ = inspect.getdoc(vendored_pandas_series.Series.truediv) + div = divide = truediv rdiv = rtruediv + rdiv.__doc__ = inspect.getdoc(vendored_pandas_series.Series.rtruediv) def __floordiv__(self, other: float | int | Series) -> Series: return self.floordiv(other) + __floordiv__.__doc__ = inspect.getdoc(vendored_pandas_series.Series.__floordiv__) + def __rfloordiv__(self, other: float | int | Series) -> Series: return self.rfloordiv(other) + __rfloordiv__.__doc__ = inspect.getdoc(vendored_pandas_series.Series.__rfloordiv__) + def floordiv(self, other: float | int | Series) -> Series: return self._apply_binary_op(other, ops.floordiv_op) @@ -698,9 +730,13 @@ def rfloordiv(self, other: float | int | Series) -> Series: def __pow__(self, other: float | int | Series) -> Series: return self.pow(other) + __pow__.__doc__ = inspect.getdoc(vendored_pandas_series.Series.__pow__) + def __rpow__(self, other: float | int | Series) -> Series: return self.rpow(other) + __rpow__.__doc__ = inspect.getdoc(vendored_pandas_series.Series.__rpow__) + def pow(self, other: float | int | Series) -> Series: return self._apply_binary_op(other, ops.pow_op) @@ -734,9 +770,13 @@ def ge(self, other) -> Series: def __mod__(self, other) -> Series: # type: ignore return self.mod(other) + __mod__.__doc__ = inspect.getdoc(vendored_pandas_series.Series.__mod__) + def __rmod__(self, other) -> Series: # type: ignore return self.rmod(other) + __rmod__.__doc__ = inspect.getdoc(vendored_pandas_series.Series.__rmod__) + def mod(self, other) -> Series: # type: ignore return self._apply_binary_op(other, ops.mod_op) @@ -753,10 +793,18 @@ def rdivmod(self, other) -> Tuple[Series, Series]: # type: ignore # the output should be dtype float, both floordiv and mod returns dtype int in this case. return (self.rfloordiv(other), self.rmod(other)) - def __matmul__(self, other): + def dot(self, other): return (self * other).sum() - dot = __matmul__ + def __matmul__(self, other): + return self.dot(other) + + __matmul__.__doc__ = inspect.getdoc(vendored_pandas_series.Series.__matmul__) + + def __rmatmul__(self, other): + return self.dot(other) + + __rmatmul__.__doc__ = inspect.getdoc(vendored_pandas_series.Series.__rmatmul__) def combine_first(self, other: Series) -> Series: result = self._apply_binary_op(other, ops.coalesce_op) @@ -849,6 +897,7 @@ def agg(self, func: str | typing.Sequence[str]) -> scalars.Scalar | Series: ) aggregate = agg + aggregate.__doc__ = inspect.getdoc(vendored_pandas_series.Series.agg) def skew(self): count = self.count() @@ -883,6 +932,7 @@ def kurt(self): return (numerator / denominator) - adjustment kurtosis = kurt + kurtosis.__doc__ = inspect.getdoc(vendored_pandas_series.Series.kurt) def mode(self) -> Series: block = self._block @@ -930,6 +980,7 @@ def prod(self) -> float: return typing.cast(float, self._apply_aggregation(agg_ops.product_op)) product = prod + product.__doc__ = inspect.getdoc(vendored_pandas_series.Series.prod) def __eq__(self, other: object) -> Series: # type: ignore return self.eq(other) @@ -940,6 +991,8 @@ def __ne__(self, other: object) -> Series: # type: ignore def __invert__(self) -> Series: return self._apply_unary_op(ops.invert_op) + __invert__.__doc__ = inspect.getdoc(vendored_pandas_series.Series.__invert__) + def eq(self, other: object) -> Series: # TODO: enforce stricter alignment return self._apply_binary_op(other, ops.eq_op) @@ -1074,6 +1127,8 @@ def __getitem__(self, indexer): return Series(block) return self.loc[indexer] + __getitem__.__doc__ = inspect.getdoc(vendored_pandas_series.Series.__getitem__) + def __getattr__(self, key: str): if hasattr(pandas.Series, key): raise AttributeError( @@ -1461,6 +1516,7 @@ def tolist(self) -> list: return self.to_pandas().to_list() to_list = tolist + to_list.__doc__ = inspect.getdoc(vendored_pandas_series.Series.tolist) def to_markdown( self, @@ -1476,7 +1532,10 @@ def to_numpy( ) -> numpy.ndarray: return self.to_pandas().to_numpy(dtype, copy, na_value, **kwargs) - __array__ = to_numpy + def __array__(self, dtype=None) -> numpy.ndarray: + return self.to_numpy(dtype=dtype) + + __array__.__doc__ = inspect.getdoc(vendored_pandas_series.Series.__array__) def to_pickle(self, path, **kwargs) -> None: return self.to_pandas().to_pickle(path, **kwargs) diff --git a/third_party/bigframes_vendored/pandas/core/frame.py b/third_party/bigframes_vendored/pandas/core/frame.py index 1fc80449d1..6707dc1403 100644 --- a/third_party/bigframes_vendored/pandas/core/frame.py +++ b/third_party/bigframes_vendored/pandas/core/frame.py @@ -339,6 +339,7 @@ def to_gbq( [2 rows x 2 columns] Write a DataFrame to a BigQuery table with clustering columns: + >>> df = bpd.DataFrame({'col1': [1, 2], 'col2': [3, 4], 'col3': [5, 6]}) >>> clustering_cols = ['col1', 'col3'] >>> df.to_gbq( @@ -910,28 +911,6 @@ def to_orc(self, path=None, **kwargs) -> bytes | None: # ---------------------------------------------------------------------- # Unsorted - def equals(self, other) -> bool: - """ - Test whether two objects contain the same elements. - - This function allows two Series or DataFrames to be compared against - each other to see if they have the same shape and elements. NaNs in - the same location are considered equal. - - The row/column index do not need to have the same type, as long - as the values are considered equal. Corresponding columns must be of - the same dtype. - - Args: - other (Series or DataFrame): - The other Series or DataFrame to be compared with the first. - - Returns: - bool: True if all elements are the same in both objects, False - otherwise. - """ - raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) - def assign(self, **kwargs) -> DataFrame: r""" Assign new columns to a DataFrame. @@ -1208,7 +1187,6 @@ def rename_axis(self, mapper: Optional[str], **kwargs) -> DataFrame: Set the name of the axis for the index. .. note:: - Currently only accepts a single string parameter (the new name of the index). Args: @@ -1862,7 +1840,7 @@ def sort_index( raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) # ---------------------------------------------------------------------- - # Arithmetic Methods + # Arithmetic and Logical Methods def eq(self, other, axis: str | int = "columns") -> DataFrame: """ @@ -1890,7 +1868,8 @@ def eq(self, other, axis: str | int = "columns") -> DataFrame: rectangle True Name: degrees, dtype: boolean - You can also use arithmetic operator ``==``: + You can also use logical operator `==`: + >>> df["degrees"] == 360 circle True triangle False @@ -1909,6 +1888,39 @@ def eq(self, other, axis: str | int = "columns") -> DataFrame: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __eq__(self, other): + """ + Check equality of DataFrame and other, element-wise, using logical + operator `==`. + + Equivalent to `DataFrame.eq(other)`. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> df = bpd.DataFrame({ + ... 'a': [0, 3, 4], + ... 'b': [360, 0, 180] + ... }) + >>> df == 0 + a b + 0 True False + 1 False True + 2 False False + + [3 rows x 2 columns] + + Args: + other (scalar or DataFrame): + Object to be compared to the DataFrame for equality. + + Returns: + DataFrame: The result of comparing `other` to DataFrame. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def ne(self, other, axis: str | int = "columns") -> DataFrame: """ Get not equal to of DataFrame and other, element-wise (binary operator `ne`). @@ -1954,6 +1966,39 @@ def ne(self, other, axis: str | int = "columns") -> DataFrame: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __ne__(self, other): + """ + Check inequality of DataFrame and other, element-wise, using logical + operator `!=`. + + Equivalent to `DataFrame.ne(other)`. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> df = bpd.DataFrame({ + ... 'a': [0, 3, 4], + ... 'b': [360, 0, 180] + ... }) + >>> df != 0 + a b + 0 False True + 1 True False + 2 True True + + [3 rows x 2 columns] + + Args: + other (scalar or DataFrame): + Object to be compared to the DataFrame for inequality. + + Returns: + DataFrame: The result of comparing `other` to DataFrame. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def le(self, other, axis: str | int = "columns") -> DataFrame: """Get 'less than or equal to' of dataframe and other, element-wise (binary operator `<=`). @@ -2004,6 +2049,39 @@ def le(self, other, axis: str | int = "columns") -> DataFrame: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __le__(self, other): + """ + Check whether DataFrame is less than or equal to other, element-wise, + using logical operator `<=`. + + Equivalent to `DataFrame.le(other)`. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> df = bpd.DataFrame({ + ... 'a': [0, -1, 1], + ... 'b': [1, 0, -1] + ... }) + >>> df <= 0 + a b + 0 True False + 1 True True + 2 False True + + [3 rows x 2 columns] + + Args: + other (scalar or DataFrame): + Object to be compared to the DataFrame. + + Returns: + DataFrame: The result of comparing `other` to DataFrame. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def lt(self, other, axis: str | int = "columns") -> DataFrame: """Get 'less than' of DataFrame and other, element-wise (binary operator `<`). @@ -2054,6 +2132,39 @@ def lt(self, other, axis: str | int = "columns") -> DataFrame: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __lt__(self, other): + """ + Check whether DataFrame is less than other, element-wise, using logical + operator `<`. + + Equivalent to `DataFrame.lt(other)`. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> df = bpd.DataFrame({ + ... 'a': [0, -1, 1], + ... 'b': [1, 0, -1] + ... }) + >>> df < 0 + a b + 0 False False + 1 True False + 2 False True + + [3 rows x 2 columns] + + Args: + other (scalar or DataFrame): + Object to be compared to the DataFrame. + + Returns: + DataFrame: The result of comparing `other` to DataFrame. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def ge(self, other, axis: str | int = "columns") -> DataFrame: """Get 'greater than or equal to' of DataFrame and other, element-wise (binary operator `>=`). @@ -2104,6 +2215,39 @@ def ge(self, other, axis: str | int = "columns") -> DataFrame: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __ge__(self, other): + """ + Check whether DataFrame is greater than or equal to other, element-wise, + using logical operator `>=`. + + Equivalent to `DataFrame.ge(other)`. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> df = bpd.DataFrame({ + ... 'a': [0, -1, 1], + ... 'b': [1, 0, -1] + ... }) + >>> df >= 0 + a b + 0 True True + 1 False True + 2 True False + + [3 rows x 2 columns] + + Args: + other (scalar or DataFrame): + Object to be compared to the DataFrame. + + Returns: + DataFrame: The result of comparing `other` to DataFrame. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def gt(self, other, axis: str | int = "columns") -> DataFrame: """Get 'greater than' of DataFrame and other, element-wise (binary operator `>`). @@ -2152,6 +2296,39 @@ def gt(self, other, axis: str | int = "columns") -> DataFrame: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __gt__(self, other): + """ + Check whether DataFrame is greater than other, element-wise, using logical + operator `>`. + + Equivalent to `DataFrame.gt(other)`. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> df = bpd.DataFrame({ + ... 'a': [0, -1, 1], + ... 'b': [1, 0, -1] + ... }) + >>> df > 0 + a b + 0 False True + 1 False False + 2 True False + + [3 rows x 2 columns] + + Args: + other (scalar or DataFrame): + Object to be compared to the DataFrame. + + Returns: + DataFrame: The result of comparing `other` to DataFrame. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def add(self, other, axis: str | int = "columns") -> DataFrame: """Get addition of DataFrame and other, element-wise (binary operator `+`). @@ -2183,7 +2360,126 @@ def add(self, other, axis: str | int = "columns") -> DataFrame: You can also use arithmetic operator ``+``: - >>> df['A'] + (df['B']) + >>> df['A'] + df['B'] + 0 5 + 1 7 + 2 9 + dtype: Int64 + + Args: + other (float, int, or Series): + Any single or multiple element data structure, or list-like object. + axis ({0 or 'index', 1 or 'columns'}): + Whether to compare by the index (0 or 'index') or columns. + (1 or 'columns'). For Series input, axis to match Series index on. + + Returns: + DataFrame: DataFrame result of the arithmetic operation. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + + def __add__(self, other) -> DataFrame: + """Get addition of DataFrame and other, column-wise, using arithmatic + operator `+`. + + Equivalent to ``DataFrame.add(other)``. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> df = bpd.DataFrame({ + ... 'height': [1.5, 2.6], + ... 'weight': [500, 800] + ... }, + ... index=['elk', 'moose']) + >>> df + height weight + elk 1.5 500 + moose 2.6 800 + + [2 rows x 2 columns] + + Adding a scalar affects all rows and columns. + + >>> df + 1.5 + height weight + elk 3.0 501.5 + moose 4.1 801.5 + + [2 rows x 2 columns] + + You can add another DataFrame with index and columns aligned. + + >>> delta = bpd.DataFrame({ + ... 'height': [0.5, 0.9], + ... 'weight': [50, 80] + ... }, + ... index=['elk', 'moose']) + >>> df + delta + height weight + elk 2.0 550 + moose 3.5 880 + + [2 rows x 2 columns] + + Adding any mis-aligned index and columns will result in invalid values. + + >>> delta = bpd.DataFrame({ + ... 'depth': [0.5, 0.9, 1.0], + ... 'weight': [50, 80, 100] + ... }, + ... index=['elk', 'moose', 'bison']) + >>> df + delta + depth height weight + elk 550 + moose 880 + bison + + [3 rows x 3 columns] + + Args: + other (scalar or DataFrame): + Object to be added to the DataFrame. + + Returns: + DataFrame: The result of adding `other` to DataFrame. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + + def radd(self, other, axis: str | int = "columns") -> DataFrame: + """Get addition of DataFrame and other, element-wise (binary operator `+`). + + Equivalent to ``other + dataframe``. With reverse version, `add`. + + Among flexible wrappers (`add`, `sub`, `mul`, `div`, `mod`, `pow`) to + arithmetic operators: `+`, `-`, `*`, `/`, `//`, `%`, `**`. + + .. note:: + Mismatched indices will be unioned together. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> df = bpd.DataFrame({ + ... 'A': [1, 2, 3], + ... 'B': [4, 5, 6], + ... }) + + You can use method name: + + >>> df['A'].radd(df['B']) + 0 5 + 1 7 + 2 9 + dtype: Int64 + + You can also use arithmetic operator ``+``: + + >>> df['A'] + df['B'] 0 5 1 7 2 9 @@ -2250,6 +2546,49 @@ def sub(self, other, axis: str | int = "columns") -> DataFrame: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __sub__(self, other): + """ + Get subtraction of other from DataFrame, element-wise, using operator `-`. + + Equivalent to `DataFrame.sub(other)`. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + You can subtract a scalar: + + >>> df = bpd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}) + >>> df - 2 + a b + 0 -1 2 + 1 0 3 + 2 1 4 + + [3 rows x 2 columns] + + You can also subtract another DataFrame with index and column labels + aligned: + + >>> df1 = bpd.DataFrame({"a": [2, 2, 2], "b": [3, 3, 3]}) + >>> df - df1 + a b + 0 -1 1 + 1 0 2 + 2 1 3 + + [3 rows x 2 columns] + + Args: + other (scalar or DataFrame): + Object to subtract from the DataFrame. + + Returns: + DataFrame: The result of the subtraction. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def rsub(self, other, axis: str | int = "columns") -> DataFrame: """Get subtraction of DataFrame and other, element-wise (binary operator `-`). @@ -2296,6 +2635,21 @@ def rsub(self, other, axis: str | int = "columns") -> DataFrame: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __rsub__(self, other): + """ + Get subtraction of DataFrame from other, element-wise, using operator `-`. + + Equivalent to `DataFrame.rsub(other)`. + + Args: + other (scalar or DataFrame): + Object to subtract the DataFrame from. + + Returns: + DataFrame: The result of the subtraction. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def mul(self, other, axis: str | int = "columns") -> DataFrame: """Get multiplication of DataFrame and other, element-wise (binary operator `*`). @@ -2345,6 +2699,141 @@ def mul(self, other, axis: str | int = "columns") -> DataFrame: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __mul__(self, other): + """ + Get multiplication of DataFrame with other, element-wise, using operator `*`. + + Equivalent to `DataFrame.mul(other)`. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + You can multiply with a scalar: + + >>> df = bpd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}) + >>> df * 3 + a b + 0 3 12 + 1 6 15 + 2 9 18 + + [3 rows x 2 columns] + + You can also multiply with another DataFrame with index and column labels + aligned: + + >>> df1 = bpd.DataFrame({"a": [2, 2, 2], "b": [3, 3, 3]}) + >>> df * df1 + a b + 0 2 12 + 1 4 15 + 2 6 18 + + [3 rows x 2 columns] + + Args: + other (scalar or DataFrame): + Object to multiply with the DataFrame. + + Returns: + DataFrame: The result of the multiplication. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + + def rmul(self, other, axis: str | int = "columns") -> DataFrame: + """Get multiplication of DataFrame and other, element-wise (binary operator `*`). + + Equivalent to ``other * dataframe``. With reverse version, `mul`. + + Among flexible wrappers (`add`, `sub`, `mul`, `div`, `mod`, `pow`) to + arithmetic operators: `+`, `-`, `*`, `/`, `//`, `%`, `**`. + + .. note:: + Mismatched indices will be unioned together. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> df = bpd.DataFrame({ + ... 'A': [1, 2, 3], + ... 'B': [4, 5, 6], + ... }) + + You can use method name: + + >>> df['A'].rmul(df['B']) + 0 4 + 1 10 + 2 18 + dtype: Int64 + + You can also use arithmetic operator ``*``: + + >>> df['A'] * (df['B']) + 0 4 + 1 10 + 2 18 + dtype: Int64 + + Args: + other (float, int, or Series): + Any single or multiple element data structure, or list-like object. + axis ({0 or 'index', 1 or 'columns'}): + Whether to compare by the index (0 or 'index') or columns. + (1 or 'columns'). For Series input, axis to match Series index on. + + Returns: + DataFrame: DataFrame result of the arithmetic operation. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + + def __rmul__(self, other): + """ + Get multiplication of DataFrame with other, element-wise, using operator `*`. + + Equivalent to `DataFrame.rmul(other)`. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + You can multiply with a scalar: + + >>> df = bpd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}) + >>> df * 3 + a b + 0 3 12 + 1 6 15 + 2 9 18 + + [3 rows x 2 columns] + + You can also multiply with another DataFrame with index and column labels + aligned: + + >>> df1 = bpd.DataFrame({"a": [2, 2, 2], "b": [3, 3, 3]}) + >>> df * df1 + a b + 0 2 12 + 1 4 15 + 2 6 18 + + [3 rows x 2 columns] + + Args: + other (scalar or DataFrame): + Object to multiply the DataFrame with. + + Returns: + DataFrame: The result of the multiplication. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def truediv(self, other, axis: str | int = "columns") -> DataFrame: """Get floating division of DataFrame and other, element-wise (binary operator `/`). @@ -2383,14 +2872,57 @@ def truediv(self, other, axis: str | int = "columns") -> DataFrame: dtype: Float64 Args: - other (float, int, or Series): - Any single or multiple element data structure, or list-like object. - axis ({0 or 'index', 1 or 'columns'}): - Whether to compare by the index (0 or 'index') or columns. - (1 or 'columns'). For Series input, axis to match Series index on. + other (float, int, or Series): + Any single or multiple element data structure, or list-like object. + axis ({0 or 'index', 1 or 'columns'}): + Whether to compare by the index (0 or 'index') or columns. + (1 or 'columns'). For Series input, axis to match Series index on. + + Returns: + DataFrame: DataFrame result of the arithmetic operation. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + + def __truediv__(self, other): + """ + Get division of DataFrame by other, element-wise, using operator `/`. + + Equivalent to `DataFrame.truediv(other)`. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + You can multiply with a scalar: + + >>> df = bpd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}) + >>> df / 2 + a b + 0 0.5 2.0 + 1 1.0 2.5 + 2 1.5 3.0 + + [3 rows x 2 columns] + + You can also multiply with another DataFrame with index and column labels + aligned: + + >>> denominator = bpd.DataFrame({"a": [2, 2, 2], "b": [3, 3, 3]}) + >>> df / denominator + a b + 0 0.5 1.333333 + 1 1.0 1.666667 + 2 1.5 2.0 + + [3 rows x 2 columns] + + Args: + other (scalar or DataFrame): + Object to divide the DataFrame by. Returns: - DataFrame: DataFrame result of the arithmetic operation. + DataFrame: The result of the division. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -2440,6 +2972,21 @@ def rtruediv(self, other, axis: str | int = "columns") -> DataFrame: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __rtruediv__(self, other): + """ + Get division of other by DataFrame, element-wise, using operator `/`. + + Equivalent to `DataFrame.rtruediv(other)`. + + Args: + other (scalar or DataFrame): + Object to divide by the DataFrame. + + Returns: + DataFrame: The result of the division. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def floordiv(self, other, axis: str | int = "columns") -> DataFrame: """Get integer division of DataFrame and other, element-wise (binary operator `//`). @@ -2489,6 +3036,49 @@ def floordiv(self, other, axis: str | int = "columns") -> DataFrame: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __floordiv__(self, other): + """ + Get integer divison of DataFrame by other, using arithmatic operator `//`. + + Equivalent to `DataFrame.floordiv(other)`. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + You can divide by a scalar: + + >>> df = bpd.DataFrame({"a": [15, 15, 15], "b": [30, 30, 30]}) + >>> df // 2 + a b + 0 7 15 + 1 7 15 + 2 7 15 + + [3 rows x 2 columns] + + You can also divide by another DataFrame with index and column labels + aligned: + + >>> divisor = bpd.DataFrame({"a": [2, 3, 4], "b": [5, 6, 7]}) + >>> df // divisor + a b + 0 7 6 + 1 5 5 + 2 3 4 + + [3 rows x 2 columns] + + Args: + other (scalar or DataFrame): + Object to divide the DataFrame by. + + Returns: + DataFrame: The result of the integer divison. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def rfloordiv(self, other, axis: str | int = "columns") -> DataFrame: """Get integer division of DataFrame and other, element-wise (binary operator `//`). @@ -2535,6 +3125,21 @@ def rfloordiv(self, other, axis: str | int = "columns") -> DataFrame: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __rfloordiv__(self, other): + """ + Get integer divison of other by DataFrame. + + Equivalent to `DataFrame.rfloordiv(other)`. + + Args: + other (scalar or DataFrame): + Object to divide by the DataFrame. + + Returns: + DataFrame: The result of the integer divison. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def mod(self, other, axis: str | int = "columns") -> DataFrame: """Get modulo of DataFrame and other, element-wise (binary operator `%`). @@ -2584,6 +3189,49 @@ def mod(self, other, axis: str | int = "columns") -> DataFrame: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __mod__(self, other): + """ + Get modulo of DataFrame with other, element-wise, using operator `%`. + + Equivalent to `DataFrame.mod(other)`. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + You can modulo with a scalar: + + >>> df = bpd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}) + >>> df % 3 + a b + 0 1 1 + 1 2 2 + 2 0 0 + + [3 rows x 2 columns] + + You can also modulo with another DataFrame with index and column labels + aligned: + + >>> modulo = bpd.DataFrame({"a": [2, 2, 2], "b": [3, 3, 3]}) + >>> df % modulo + a b + 0 1 1 + 1 0 2 + 2 1 0 + + [3 rows x 2 columns] + + Args: + other (scalar or DataFrame): + Object to modulo the DataFrame by. + + Returns: + DataFrame: The result of the modulo. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def rmod(self, other, axis: str | int = "columns") -> DataFrame: """Get modulo of DataFrame and other, element-wise (binary operator `%`). @@ -2630,6 +3278,21 @@ def rmod(self, other, axis: str | int = "columns") -> DataFrame: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __rmod__(self, other): + """ + Get integer divison of other by DataFrame. + + Equivalent to `DataFrame.rmod(other)`. + + Args: + other (scalar or DataFrame): + Object to modulo by the DataFrame. + + Returns: + DataFrame: The result of the modulo. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def pow(self, other, axis: str | int = "columns") -> DataFrame: """Get Exponential power of dataframe and other, element-wise (binary operator `**`). @@ -2680,6 +3343,50 @@ def pow(self, other, axis: str | int = "columns") -> DataFrame: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __pow__(self, other): + """ + Get exponentiation of DataFrame with other, element-wise, using operator + `**`. + + Equivalent to `DataFrame.pow(other)`. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + You can exponentiate with a scalar: + + >>> df = bpd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}) + >>> df ** 2 + a b + 0 1 16 + 1 4 25 + 2 9 36 + + [3 rows x 2 columns] + + You can also exponentiate with another DataFrame with index and column + labels aligned: + + >>> exponent = bpd.DataFrame({"a": [2, 2, 2], "b": [3, 3, 3]}) + >>> df ** exponent + a b + 0 1 64 + 1 4 125 + 2 9 216 + + [3 rows x 2 columns] + + Args: + other (scalar or DataFrame): + Object to exponentiate the DataFrame with. + + Returns: + DataFrame: The result of the exponentiation. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def rpow(self, other, axis: str | int = "columns") -> DataFrame: """Get Exponential power of dataframe and other, element-wise (binary operator `rpow`). @@ -2727,6 +3434,22 @@ def rpow(self, other, axis: str | int = "columns") -> DataFrame: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __rpow__(self, other): + """ + Get exponentiation of other with DataFrame, element-wise, using operator + `**`. + + Equivalent to `DataFrame.rpow(other)`. + + Args: + other (scalar or DataFrame): + Object to exponentiate with the DataFrame. + + Returns: + DataFrame: The result of the exponentiation. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def combine( self, other, func, fill_value=None, overwrite: bool = True ) -> DataFrame: @@ -4102,7 +4825,6 @@ def nsmallest(self, n: int, columns, keep: str = "first"): performant. .. note:: - This function cannot be used with all column types. For example, when specifying columns with `object` or `category` dtypes, ``TypeError`` is raised. @@ -5074,6 +5796,7 @@ def eval(self, expr: str) -> DataFrame: injection if you pass user input to this function. **Examples:** + >>> import bigframes.pandas as bpd >>> bpd.options.display.progress_bar = None @@ -5095,11 +5818,11 @@ def eval(self, expr: str) -> DataFrame: 4 7 dtype: Int64 - Assignment is allowed though by default the original DataFrame is not - modified. + Assignment is allowed though by default the original DataFrame is not + modified. >>> df.eval('C = A + B') - A B C + A B C 0 1 10 11 1 2 8 10 2 3 6 9 @@ -5108,7 +5831,7 @@ def eval(self, expr: str) -> DataFrame: [5 rows x 3 columns] >>> df - A B + A B 0 1 10 1 2 8 2 3 6 @@ -5117,7 +5840,7 @@ def eval(self, expr: str) -> DataFrame: [5 rows x 2 columns] - Multiple columns can be assigned to using multi-line expressions: + Multiple columns can be assigned to using multi-line expressions: >>> df.eval( ... ''' @@ -5125,7 +5848,7 @@ def eval(self, expr: str) -> DataFrame: ... D = A - B ... ''' ... ) - A B C D + A B C D 0 1 10 11 -9 1 2 8 10 -6 2 3 6 9 -3 @@ -5149,6 +5872,7 @@ def query(self, expr: str) -> DataFrame | None: Query the columns of a DataFrame with a boolean expression. **Examples:** + >>> import bigframes.pandas as bpd >>> bpd.options.display.progress_bar = None @@ -5521,6 +6245,7 @@ def dot(self, other): DataFrame and the index of other must contain the same values, as they will be aligned prior to the multiplication. + .. note:: The dot method for Series computes the inner product, instead of the matrix product here. @@ -5607,6 +6332,59 @@ def dot(self, other): """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __matmul__(self, other): + """ + Compute the matrix multiplication between the DataFrame and other, using + operator `@`. + + Equivalent to `DataFrame.dot(other)`. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> left = bpd.DataFrame([[0, 1, -2, -1], [1, 1, 1, 1]]) + >>> left + 0 1 2 3 + 0 0 1 -2 -1 + 1 1 1 1 1 + + [2 rows x 4 columns] + >>> right = bpd.DataFrame([[0, 1], [1, 2], [-1, -1], [2, 0]]) + >>> right + 0 1 + 0 0 1 + 1 1 2 + 2 -1 -1 + 3 2 0 + + [4 rows x 2 columns] + >>> left @ right + 0 1 + 0 1 4 + 1 2 2 + + [2 rows x 2 columns] + + The operand can be a Series, in which case the result will also be a + Series: + + >>> right = bpd.Series([1, 2, -1,0]) + >>> left @ right + 0 4 + 1 2 + dtype: Int64 + + Args: + other (DataFrame or Series): + Object to be matrix multiplied with the DataFrame. + + Returns: + DataFrame or Series: The result of the matrix multiplication. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + @property def plot(self): """ @@ -5617,3 +6395,197 @@ def plot(self): An accessor making plots. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + + def __len__(self): + """Returns number of rows in the DataFrame, serves `len` operator. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> df = bpd.DataFrame({ + ... 'a': [0, 1, 2], + ... 'b': [3, 4, 5] + ... }) + >>> len(df) + 3 + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + + def __array__(self): + """ + Returns the rows as NumPy array. + + Equivalent to `DataFrame.to_numpy(dtype)`. + + Users should not call this directly. Rather, it is invoked by + `numpy.array` and `numpy.asarray`. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + >>> import numpy as np + + >>> df = bpd.DataFrame({"a": [1, 2, 3], "b": [11, 22, 33]}) + + >>> np.array(df) + array([[1, 11], + [2, 22], + [3, 33]], dtype=object) + + >>> np.asarray(df) + array([[1, 11], + [2, 22], + [3, 33]], dtype=object) + + Args: + dtype (str or numpy.dtype, optional): + The dtype to use for the resulting NumPy array. By default, + the dtype is inferred from the data. + + Returns: + numpy.ndarray: + The rows in the DataFrame converted to a `numpy.ndarray` with + the specified dtype. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + + def __getitem__(self, key): + """Gets the specified column(s) from the DataFrame. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> df = bpd.DataFrame({ + ... "name" : ["alpha", "beta", "gamma"], + ... "age": [20, 30, 40], + ... "location": ["WA", "NY", "CA"] + ... }) + >>> df + name age location + 0 alpha 20 WA + 1 beta 30 NY + 2 gamma 40 CA + + [3 rows x 3 columns] + + You can specify a column label to retrieve the corresponding Series. + + >>> df["name"] + 0 alpha + 1 beta + 2 gamma + Name: name, dtype: string + + You can specify a list of column labels to retrieve a Dataframe. + + >>> df[["name", "age"]] + name age + 0 alpha 20 + 1 beta 30 + 2 gamma 40 + + [3 rows x 2 columns] + + You can specify a condition as a series of booleans to retrieve matching + rows. + + >>> df[df["age"] > 25] + name age location + 1 beta 30 NY + 2 gamma 40 CA + + [2 rows x 3 columns] + + You can specify a pandas Index with desired column labels. + + >>> import pandas as pd + >>> df[pd.Index(["age", "location"])] + age location + 0 20 WA + 1 30 NY + 2 40 CA + + [3 rows x 2 columns] + + Args: + key (index): + Index or list of indices. It can be a column label, a list of + column labels, a Series of booleans or a pandas Index of desired + column labels + + Returns: + Series or Value: Value(s) at the requested index(es). + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + + def __setitem__(self, key, value): + """Modify or insert a column into the DataFrame. + + .. note:: + This does **not** modify the original table the DataFrame was + derived from. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> df = bpd.DataFrame({ + ... "name" : ["alpha", "beta", "gamma"], + ... "age": [20, 30, 40], + ... "location": ["WA", "NY", "CA"] + ... }) + >>> df + name age location + 0 alpha 20 WA + 1 beta 30 NY + 2 gamma 40 CA + + [3 rows x 3 columns] + + You can add assign a constant to a new column. + + >>> df["country"] = "USA" + >>> df + name age location country + 0 alpha 20 WA USA + 1 beta 30 NY USA + 2 gamma 40 CA USA + + [3 rows x 4 columns] + + You can assign a Series to a new column. + + >>> df["new_age"] = df["age"] + 5 + >>> df + name age location country new_age + 0 alpha 20 WA USA 25 + 1 beta 30 NY USA 35 + 2 gamma 40 CA USA 45 + + [3 rows x 5 columns] + + You can assign a Series to an existing column. + + >>> df["new_age"] = bpd.Series([29, 39, 19], index=[1, 2, 0]) + >>> df + name age location country new_age + 0 alpha 20 WA USA 19 + 1 beta 30 NY USA 29 + 2 gamma 40 CA USA 39 + + [3 rows x 5 columns] + + Args: + key (column index): + It can be a new column to be inserted, or an existing column to + be modified. + value (scalar or Series): + Value to be assigned to the column + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) diff --git a/third_party/bigframes_vendored/pandas/core/generic.py b/third_party/bigframes_vendored/pandas/core/generic.py index baa9534a0e..9c6120fd6c 100644 --- a/third_party/bigframes_vendored/pandas/core/generic.py +++ b/third_party/bigframes_vendored/pandas/core/generic.py @@ -1120,9 +1120,39 @@ def pipe( return common.pipe(self, func, *args, **kwargs) def __nonzero__(self): + """Returns the truth value of the object.""" raise ValueError( f"The truth value of a {type(self).__name__} is ambiguous. " "Use a.empty, a.bool(), a.item(), a.any() or a.all()." ) __bool__ = __nonzero__ + + def __getattr__(self, name: str): + """ + After regular attribute access, try looking up the name + This allows simpler access to columns for interactive use. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + + def equals(self, other) -> bool: + """ + Test whether two objects contain the same elements. + + This function allows two Series or DataFrames to be compared against + each other to see if they have the same shape and elements. NaNs in + the same location are considered equal. + + The row/column index do not need to have the same type, as long + as the values are considered equal. Corresponding columns must be of + the same dtype. + + Args: + other (Series or DataFrame): + The other Series or DataFrame to be compared with the first. + + Returns: + bool: True if all elements are the same in both objects, False + otherwise. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) diff --git a/third_party/bigframes_vendored/pandas/core/series.py b/third_party/bigframes_vendored/pandas/core/series.py index 192e19fa5a..46bc9714f8 100644 --- a/third_party/bigframes_vendored/pandas/core/series.py +++ b/third_party/bigframes_vendored/pandas/core/series.py @@ -6,6 +6,7 @@ from typing import Hashable, IO, Literal, Mapping, Optional, Sequence, TYPE_CHECKING from bigframes_vendored.pandas.core.generic import NDFrame +import numpy import numpy as np from pandas._libs import lib from pandas._typing import Axis, FilePath, NaPosition, WriteBuffer @@ -961,13 +962,13 @@ def dot(self, other) -> Series | np.ndarray: def __matmul__(self, other): """ - Matrix multiplication using binary `@` operator in Python>=3.5. + Matrix multiplication using binary `@` operator. """ return NotImplemented def __rmatmul__(self, other): """ - Matrix multiplication using binary `@` operator in Python>=3.5. + Matrix multiplication using binary `@` operator. """ return NotImplemented @@ -2173,6 +2174,55 @@ def add(self, other) -> Series: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __add__(self, other): + """Get addition of Series and other, element-wise, using operator `+`. + + Equivalent to `Series.add(other)`. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> s = bpd.Series([1.5, 2.6], index=['elk', 'moose']) + >>> s + elk 1.5 + moose 2.6 + dtype: Float64 + + You can add a scalar. + + >>> s + 1.5 + elk 3.0 + moose 4.1 + dtype: Float64 + + You can add another Series with index aligned. + + >>> delta = bpd.Series([1.5, 2.6], index=['elk', 'moose']) + >>> s + delta + elk 3.0 + moose 5.2 + dtype: Float64 + + Adding any mis-aligned index will result in invalid values. + + >>> delta = bpd.Series([1.5, 2.6], index=['moose', 'bison']) + >>> s + delta + elk + moose 4.1 + bison + dtype: Float64 + + Args: + other (scalar or Series): + Object to be added to the Series. + + Returns: + Series: The result of adding `other` to Series. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def radd(self, other) -> Series: """Return addition of Series and other, element-wise (binary operator radd). @@ -2188,6 +2238,20 @@ def radd(self, other) -> Series: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __radd__(self, other): + """Get addition of Series and other, element-wise, using operator `+`. + + Equivalent to `Series.radd(other)`. + + Args: + other (scalar or Series): + Object to which Series should be added. + + Returns: + Series: The result of adding Series to `other`. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def sub( self, other, @@ -2206,6 +2270,55 @@ def sub( """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __sub__(self, other): + """Get subtraction of other from Series, element-wise, using operator `-`. + + Equivalent to `Series.sub(other)`. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> s = bpd.Series([1.5, 2.6], index=['elk', 'moose']) + >>> s + elk 1.5 + moose 2.6 + dtype: Float64 + + You can subtract a scalar. + + >>> s - 1.5 + elk 0.0 + moose 1.1 + dtype: Float64 + + You can subtract another Series with index aligned. + + >>> delta = bpd.Series([0.5, 1.0], index=['elk', 'moose']) + >>> s - delta + elk 1.0 + moose 1.6 + dtype: Float64 + + Adding any mis-aligned index will result in invalid values. + + >>> delta = bpd.Series([0.5, 1.0], index=['moose', 'bison']) + >>> s - delta + elk + moose 2.1 + bison + dtype: Float64 + + Args: + other (scalar or Series): + Object to subtract from the Series. + + Returns: + Series: The result of subtraction. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def rsub(self, other) -> Series: """Return subtraction of Series and other, element-wise (binary operator rsub). @@ -2221,6 +2334,20 @@ def rsub(self, other) -> Series: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __rsub__(self, other): + """Get subtraction of Series from other, element-wise, using operator `-`. + + Equivalent to `Series.rsub(other)`. + + Args: + other (scalar or Series): + Object to subtract the Series from. + + Returns: + Series: The result of subtraction. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def mul(self, other) -> Series: """Return multiplication of Series and other, element-wise (binary operator mul). @@ -2236,6 +2363,44 @@ def mul(self, other) -> Series: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __mul__(self, other): + """ + Get multiplication of Series with other, element-wise, using operator `*`. + + Equivalent to `Series.mul(other)`. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + You can multiply with a scalar: + + >>> s = bpd.Series([1, 2, 3]) + >>> s * 3 + 0 3 + 1 6 + 2 9 + dtype: Int64 + + You can also multiply with another Series: + + >>> s1 = bpd.Series([2, 3, 4]) + >>> s * s1 + 0 2 + 1 6 + 2 12 + dtype: Int64 + + Args: + other (scalar or Series): + Object to multiply with the Series. + + Returns: + Series: The result of the multiplication. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def rmul(self, other) -> Series: """Return multiplication of Series and other, element-wise (binary operator mul). @@ -2250,6 +2415,21 @@ def rmul(self, other) -> Series: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __rmul__(self, other): + """ + Get multiplication of other with Series, element-wise, using operator `*`. + + Equivalent to `Series.rmul(other)`. + + Args: + other (scalar or Series): + Object to multiply the Series with. + + Returns: + Series: The result of the multiplication. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def truediv(self, other) -> Series: """Return floating division of Series and other, element-wise (binary operator truediv). @@ -2265,6 +2445,44 @@ def truediv(self, other) -> Series: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __truediv__(self, other): + """ + Get division of Series by other, element-wise, using operator `/`. + + Equivalent to `Series.truediv(other)`. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + You can multiply with a scalar: + + >>> s = bpd.Series([1, 2, 3]) + >>> s / 2 + 0 0.5 + 1 1.0 + 2 1.5 + dtype: Float64 + + You can also multiply with another Series: + + >>> denominator = bpd.Series([2, 3, 4]) + >>> s / denominator + 0 0.5 + 1 0.666667 + 2 0.75 + dtype: Float64 + + Args: + other (scalar or Series): + Object to divide the Series by. + + Returns: + Series: The result of the division. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def rtruediv(self, other) -> Series: """Return floating division of Series and other, element-wise (binary operator rtruediv). @@ -2280,6 +2498,21 @@ def rtruediv(self, other) -> Series: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __rtruediv__(self, other): + """ + Get division of other by Series, element-wise, using operator `/`. + + Equivalent to `Series.rtruediv(other)`. + + Args: + other (scalar or Series): + Object to divide by the Series. + + Returns: + Series: The result of the division. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def floordiv(self, other) -> Series: """Return integer division of Series and other, element-wise (binary operator floordiv). @@ -2295,6 +2528,44 @@ def floordiv(self, other) -> Series: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __floordiv__(self, other): + """ + Get integer divison of Series by other, using arithmatic operator `//`. + + Equivalent to `Series.floordiv(other)`. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + You can divide by a scalar: + + >>> s = bpd.Series([15, 30, 45]) + >>> s // 2 + 0 7 + 1 15 + 2 22 + dtype: Int64 + + You can also divide by another DataFrame: + + >>> divisor = bpd.Series([3, 4, 4]) + >>> s // divisor + 0 5 + 1 7 + 2 11 + dtype: Int64 + + Args: + other (scalar or Series): + Object to divide the Series by. + + Returns: + Series: The result of the integer divison. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def rfloordiv(self, other) -> Series: """Return integer division of Series and other, element-wise (binary operator rfloordiv). @@ -2310,6 +2581,21 @@ def rfloordiv(self, other) -> Series: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __rfloordiv__(self, other): + """ + Get integer divison of other by Series, using arithmatic operator `//`. + + Equivalent to `Series.rfloordiv(other)`. + + Args: + other (scalar or Series): + Object to divide by the Series. + + Returns: + Series: The result of the integer divison. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def mod(self, other) -> Series: """Return modulo of Series and other, element-wise (binary operator mod). @@ -2325,6 +2611,44 @@ def mod(self, other) -> Series: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __mod__(self, other): + """ + Get modulo of Series with other, element-wise, using operator `%`. + + Equivalent to `Series.mod(other)`. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + You can modulo with a scalar: + + >>> s = bpd.Series([1, 2, 3]) + >>> s % 3 + 0 1 + 1 2 + 2 0 + dtype: Int64 + + You can also modulo with another Series: + + >>> modulo = bpd.Series([3, 3, 3]) + >>> s % modulo + 0 1 + 1 2 + 2 0 + dtype: Int64 + + Args: + other (scalar or Series): + Object to modulo the Series by. + + Returns: + Series: The result of the modulo. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def rmod(self, other) -> Series: """Return modulo of Series and other, element-wise (binary operator mod). @@ -2340,6 +2664,21 @@ def rmod(self, other) -> Series: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __rmod__(self, other): + """ + Get modulo of other with Series, element-wise, using operator `%`. + + Equivalent to `Series.rmod(other)`. + + Args: + other (scalar or Series): + Object to modulo by the Series. + + Returns: + Series: The result of the modulo. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def pow(self, other) -> Series: """Return Exponential power of series and other, element-wise (binary operator `pow`). @@ -2355,6 +2694,45 @@ def pow(self, other) -> Series: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __pow__(self, other): + """ + Get exponentiation of Series with other, element-wise, using operator + `**`. + + Equivalent to `Series.pow(other)`. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + You can exponentiate with a scalar: + + >>> s = bpd.Series([1, 2, 3]) + >>> s ** 2 + 0 1 + 1 4 + 2 9 + dtype: Int64 + + You can also exponentiate with another Series: + + >>> exponent = bpd.Series([3, 2, 1]) + >>> s ** exponent + 0 1 + 1 4 + 2 3 + dtype: Int64 + + Args: + other (scalar or Series): + Object to exponentiate the Series with. + + Returns: + Series: The result of the exponentiation. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def rpow(self, other) -> Series: """Return Exponential power of series and other, element-wise (binary operator `rpow`). @@ -2370,6 +2748,22 @@ def rpow(self, other) -> Series: """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def __rpow__(self, other): + """ + Get exponentiation of other with Series, element-wise, using operator + `**`. + + Equivalent to `Series.rpow(other)`. + + Args: + other (scalar or Series): + Object to exponentiate with the Series. + + Returns: + Series: The result of the exponentiation. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def divmod(self, other) -> Series: """Return integer division and modulo of Series and other, element-wise (binary operator divmod). @@ -3574,3 +3968,172 @@ def size(self) -> int: int: Return the number of elements in the underlying data. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + + def __array__(self, dtype=None) -> numpy.ndarray: + """ + Returns the values as NumPy array. + + Equivalent to `Series.to_numpy(dtype)`. + + Users should not call this directly. Rather, it is invoked by + `numpy.array` and `numpy.asarray`. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + >>> import numpy as np + + >>> ser = bpd.Series([1, 2, 3]) + + >>> np.asarray(ser) + array([1, 2, 3]) + + Args: + dtype (str or numpy.dtype, optional): + The dtype to use for the resulting NumPy array. By default, + the dtype is inferred from the data. + + Returns: + numpy.ndarray: + The values in the series converted to a `numpy.ndarray` with the + specified dtype. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + + def __len__(self): + """Returns number of values in the Series, serves `len` operator. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> s = bpd.Series([1, 2, 3]) + >>> len(s) + 3 + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + + def __invert__(self): + """ + Returns the logical inversion (binary NOT) of the Series, element-wise + using operator `~`. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> ser = bpd.Series([True, False, True]) + >>> ~ser + 0 False + 1 True + 2 False + dtype: boolean + + Returns: + Series: The inverted values in the series. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + + def __and__(self, other): + """Get bitwise AND of Series and other, element-wise, using operator `&`. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> s = bpd.Series([0, 1, 2, 3]) + + You can operate with a scalar. + + >>> s & 6 + 0 0 + 1 0 + 2 2 + 3 2 + dtype: Int64 + + You can operate with another Series. + + >>> s1 = bpd.Series([5, 6, 7, 8]) + >>> s & s1 + 0 0 + 1 0 + 2 2 + 3 0 + dtype: Int64 + + Args: + other (scalar or Series): + Object to bitwise AND with the Series. + + Returns: + Series: The result of the operation. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + + def __or__(self, other): + """Get bitwise OR of Series and other, element-wise, using operator `|`. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> s = bpd.Series([0, 1, 2, 3]) + + You can operate with a scalar. + + >>> s | 6 + 0 6 + 1 7 + 2 6 + 3 7 + dtype: Int64 + + You can operate with another Series. + + >>> s1 = bpd.Series([5, 6, 7, 8]) + >>> s | s1 + 0 5 + 1 7 + 2 7 + 3 11 + dtype: Int64 + + Args: + other (scalar or Series): + Object to bitwise OR with the Series. + + Returns: + Series: The result of the operation. + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + + def __getitem__(self, indexer): + """Gets the specified index from the Series. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> s = bpd.Series([15, 30, 45]) + >>> s[1] + 30 + >>> s[0:2] + 0 15 + 1 30 + dtype: Int64 + + Args: + indexer (int or slice): + Index or slice of indices. + + Returns: + Series or Value: Value(s) at the requested index(es). + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE)