diff --git a/third_party/bigframes_vendored/pandas/core/generic.py b/third_party/bigframes_vendored/pandas/core/generic.py index 2885162fd6..c079cbff7f 100644 --- a/third_party/bigframes_vendored/pandas/core/generic.py +++ b/third_party/bigframes_vendored/pandas/core/generic.py @@ -448,6 +448,67 @@ def copy(self): and indices. Modifications to the data or indices of the copy will not be reflected in the original object. + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + Modification in the original Series will not affect the copy Series: + + >>> s = bpd.Series([1, 2], index=["a", "b"]) + >>> s + a 1 + b 2 + dtype: Int64 + + >>> s_copy = s.copy() + >>> s_copy + a 1 + b 2 + dtype: Int64 + + >>> s.loc['b'] = 22 + >>> s + a 1 + b 22 + dtype: Int64 + >>> s_copy + a 1 + b 2 + dtype: Int64 + + Modification in the original DataFrame will not affect the copy DataFrame: + + >>> df = bpd.DataFrame({'a': [1, 3], 'b': [2, 4]}) + >>> df + a b + 0 1 2 + 1 3 4 + + [2 rows x 2 columns] + + >>> df_copy = df.copy() + >>> df_copy + a b + 0 1 2 + 1 3 4 + + [2 rows x 2 columns] + + >>> df.loc[df["b"] == 2, "b"] = 22 + >>> df + a b + 0 1 22.0 + 1 3 4.0 + + [2 rows x 2 columns] + >>> df_copy + a b + 0 1 2 + 1 3 4 + + [2 rows x 2 columns] + Returns: Object type matches caller. """ diff --git a/third_party/bigframes_vendored/pandas/core/series.py b/third_party/bigframes_vendored/pandas/core/series.py index b0a4cb8193..b97f9018dd 100644 --- a/third_party/bigframes_vendored/pandas/core/series.py +++ b/third_party/bigframes_vendored/pandas/core/series.py @@ -433,6 +433,21 @@ def tolist(self) -> list: (for str, int, float) or a pandas scalar (for Timestamp/Timedelta/Interval/Period). + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> s = bpd.Series([1, 2, 3]) + >>> s + 0 1 + 1 2 + 2 3 + dtype: Int64 + + >>> s.to_list() + [1, 2, 3] + Returns: list: list of the values """ @@ -560,6 +575,20 @@ def count(self): """ Return number of non-NA/null observations in the Series. + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> s = bpd.Series([0.0, 1.0, bpd.NA]) + >>> s + 0 0.0 + 1 1.0 + 2 + dtype: Float64 + >>> s.count() + 2 + Returns: int or Series (if level specified): Number of non-null values in the Series. @@ -2845,6 +2874,47 @@ def map( ``__missing__`` (i.e. provide a method for default values). These are treated the same as ``dict``. + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> s = bpd.Series(['cat', 'dog', bpd.NA, 'rabbit']) + >>> s + 0 cat + 1 dog + 2 + 3 rabbit + dtype: string + + `map` can accepts a `dict`. Values that are not found in the `dict` are + converted to `NA`: + + >>> s.map({'cat': 'kitten', 'dog': 'puppy'}) + 0 kitten + 1 puppy + 2 + 3 + dtype: string + + It also accepts a remote function: + + >>> @bpd.remote_function([str], str) + ... def my_mapper(val): + ... vowels = ["a", "e", "i", "o", "u"] + ... if val: + ... return "".join([ + ... ch.upper() if ch in vowels else ch for ch in val + ... ]) + ... return "N/A" + + >>> s.map(my_mapper) + 0 cAt + 1 dOg + 2 N/A + 3 rAbbIt + dtype: string + Args: arg (function, Mapping, Series): remote function, collections.abc.Mapping subclass or Series