From 1871ed2ceb3a7040aea309b376fce95b77de9c31 Mon Sep 17 00:00:00 2001 From: Arwa Date: Wed, 6 Nov 2024 15:50:35 -0600 Subject: [PATCH 01/15] docs: update `bigframes.pandas.Index` docstrings --- .../pandas/core/indexes/base.py | 128 +++++++++++++++++- 1 file changed, 122 insertions(+), 6 deletions(-) diff --git a/third_party/bigframes_vendored/pandas/core/indexes/base.py b/third_party/bigframes_vendored/pandas/core/indexes/base.py index b0e1a09392..c98c45d209 100644 --- a/third_party/bigframes_vendored/pandas/core/indexes/base.py +++ b/third_party/bigframes_vendored/pandas/core/indexes/base.py @@ -26,40 +26,156 @@ class Index: @property def name(self): - """Returns Index name.""" + """Returns Index name. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> idx = bpd.Index([1, 2, 3], name='x') + Index([1, 2, 3], dtype='Int64', name='x') + >>> idx.name + 'x' + + Returns: + blocks.Label: + Index or MultiIndex name + + """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @property def values(self): - """Return an array representing the data in the Index.""" + """Return an array representing the data in the Index. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> idx = bpd.Index([1, 2, 3]) + >>> idx + Index([1, 2, 3], dtype='Int64') + + >>> idx.values + array([1, 2, 3]) + + Returns: + array: + Numpy.ndarray or ExtensionArray + + """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @property def shape(self): """ Return a tuple of the shape of the underlying data. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> idx = pd.Index([1, 2, 3]) + >>> idx + Index([1, 2, 3], dtype='Int64') + + >>> idx.shape + (3,) + + Returns: + Tuple[int]: + A tuple of int representing the shape. + """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @property def nlevels(self) -> int: - """Number of levels.""" + """Integer number of levels in this MultiIndex + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> mi = bpd.MultiIndex.from_arrays([['a'], ['b'], ['c']]) + >>> mi + MultiIndex([('a', 'b', 'c')], + ... ) + >>> mi.nlevels + 3 + + Returns: + Int: + Number of levels. + + """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @property def is_unique(self) -> bool: - """Return if the index has unique values.""" + """Return if the index has unique values. + + **Examples:** + + >>> idx = bpd.Index([1, 5, 7, 7]) + >>> idx.is_unique + False + + >>> idx = bpd.Index([1, 5, 7]) + >>> idx.is_unique + True + + Returns: + bool: + True if the index has unique values, otherwise False. + """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @property def has_duplicates(self) -> bool: - """Check if the Index has duplicate values.""" + """Check if the Index has duplicate values. + + **Examples:** + + >>> idx = bpd.Index([1, 5, 7, 7]) + >>> idx.has_duplicates + True + + >>> idx = bpd.Index([1, 5, 7]) + >>> idx.has_duplicates + False + + >>> idx = pd.Index(["Watermelon", "Orange", "Apple", + ... "Watermelon"]).astype("category") + >>> idx.has_duplicates + True + + >>> idx = pd.Index(["Orange", "Apple", + ... "Watermelon"]).astype("category") + >>> idx.has_duplicates + False + + + """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @property def dtype(self): - """Return the dtype object of the underlying data.""" + """Return the dtype object of the underlying data. + + **Examples:** + >>> idx = bpd.Index([1, 2, 3]) + >>> idx + Index([1, 2, 3], dtype='Int64') + + >>> idx.dtype + Int64Dtype() + """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @property From 8bcb37c471327ad5d5fb7d6b3f53167821ff14f4 Mon Sep 17 00:00:00 2001 From: Arwa Date: Wed, 13 Nov 2024 15:43:50 -0600 Subject: [PATCH 02/15] updating more methods --- .../pandas/core/indexes/base.py | 117 ++++++++++++++++-- 1 file changed, 106 insertions(+), 11 deletions(-) diff --git a/third_party/bigframes_vendored/pandas/core/indexes/base.py b/third_party/bigframes_vendored/pandas/core/indexes/base.py index c98c45d209..5afa1977e4 100644 --- a/third_party/bigframes_vendored/pandas/core/indexes/base.py +++ b/third_party/bigframes_vendored/pandas/core/indexes/base.py @@ -41,7 +41,6 @@ def name(self): Returns: blocks.Label: Index or MultiIndex name - """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -64,7 +63,6 @@ def values(self): Returns: array: Numpy.ndarray or ExtensionArray - """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -88,7 +86,6 @@ def shape(self): Returns: Tuple[int]: A tuple of int representing the shape. - """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -111,7 +108,6 @@ def nlevels(self) -> int: Returns: Int: Number of levels. - """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -121,6 +117,9 @@ def is_unique(self) -> bool: **Examples:** + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + >>> idx = bpd.Index([1, 5, 7, 7]) >>> idx.is_unique False @@ -141,6 +140,9 @@ def has_duplicates(self) -> bool: **Examples:** + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + >>> idx = bpd.Index([1, 5, 7, 7]) >>> idx.has_duplicates True @@ -159,7 +161,9 @@ def has_duplicates(self) -> bool: >>> idx.has_duplicates False - + Returns: + bool: + True if the Index has duplicate values, otherwise False. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -169,6 +173,9 @@ def dtype(self): **Examples:** + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + >>> idx = bpd.Index([1, 2, 3]) >>> idx Index([1, 2, 3], dtype='Int64') @@ -180,12 +187,40 @@ def dtype(self): @property def dtypes(self): - """Return the dtypes as a Series for the underlying MultiIndex.""" + """Return the dtypes as a Series for the underlying MultiIndex. + + Returns: + Pandas.Series: + Pandas.Series of the MultiIndex dtypes. + """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @property def T(self) -> Index: - """Return the transpose, which is by definition self.""" + """Return the transpose, which is by definition self. + + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> s = bpd.Series(['Ant', 'Bear', 'Cow']) + >>> s + 0 Ant + 1 Bear + 2 Cow + dtype: string + + >>> s.T + + For Index: + + >>> idx = bpd.Index([1, 2, 3]) + >>> idx.T + Index([1, 2, 3], dtype='Int64') + + Returns: + """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) def copy( @@ -197,11 +232,23 @@ def copy( Name is set on the new object. + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> idx = pd.Index(['a', 'b', 'c']) + >>> new_idx = idx.copy() + >>> idx is new_idx + False + Args: name (Label, optional): Set name for new object. + Returns: - Index: Index reference to new object, which is a copy of this object. + Index: + Index reference to new object, which is a copy of this object. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -210,7 +257,8 @@ def transpose(self) -> Index: Return the transpose, which is by definition self. Returns: - Index + bigframes.pandas.Index + An Index. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -220,6 +268,16 @@ def astype(self, dtype): The class of a new Index is determined by dtype. When conversion is impossible, a TypeError exception is raised. + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> idx = pd.Index([1, 2, 3]) + >>> idx + Index([1, 2, 3], dtype='Int64') + + Args: dtype (numpy dtype or pandas type): @@ -235,12 +293,25 @@ def get_level_values(self, level) -> Index: This is primarily useful to get an individual level of values from a MultiIndex, but is provided on Index as well for compatibility. + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> idx = bpd.Index(list('abc')) + >>> idx + Index(['a', 'b', 'c'], dtype='string') + + >>> idx.get_level_values(0) + Index(['a', 'b', 'c'], dtype='string') + Args: level (int or str): It is either the integer position or the name of the level. Returns: - Index: Calling object, as there is only one level in the Index. + Index: + Calling object, as there is only one level in the Index. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -250,6 +321,29 @@ def to_series(self): Useful with map for returning an indexer based on an index. + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + animal + Ant Ant + Bear Bear + Cow Cow + Name: animal, dtype: string + + >>> idx.to_series(index=[0, 1, 2]) + 0 Ant + 1 Bear + 2 Cow + Name: animal, dtype: string + + >>> idx.to_series(name='zoo') + animal + Ant Ant + Bear Bear + Cow Cow + Name: zoo, dtype: string + Args: index (Index, optional): Index of resulting Series. If None, defaults to original index. @@ -258,7 +352,8 @@ def to_series(self): index. Returns: - Series: The dtype will be based on the type of the Index values. + bigframes.pandas.Series: + The dtype will be based on the type of the Index values. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) From 587d47973ba57485f38392838b1e0148775fbae3 Mon Sep 17 00:00:00 2001 From: Arwa Date: Thu, 14 Nov 2024 16:21:55 -0600 Subject: [PATCH 03/15] update docstrings of more methods --- .../pandas/core/indexes/base.py | 46 ++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/third_party/bigframes_vendored/pandas/core/indexes/base.py b/third_party/bigframes_vendored/pandas/core/indexes/base.py index 5afa1977e4..54128bd0d2 100644 --- a/third_party/bigframes_vendored/pandas/core/indexes/base.py +++ b/third_party/bigframes_vendored/pandas/core/indexes/base.py @@ -325,18 +325,28 @@ def to_series(self): >>> import bigframes.pandas as bpd >>> bpd.options.display.progress_bar = None + + >>> idx = pd.Index(['Ant', 'Bear', 'Cow'], name='animal') + + By default, the original index and original name is reused. + + >>> idx.to_series() animal Ant Ant Bear Bear Cow Cow Name: animal, dtype: string + To enforce a new index, specify new labels to index: + >>> idx.to_series(index=[0, 1, 2]) 0 Ant 1 Bear 2 Cow Name: animal, dtype: string + To override the name of the resulting column, specify name: + >>> idx.to_series(name='zoo') animal Ant Ant @@ -377,16 +387,48 @@ def isin(self, values): def all(self) -> bool: """Return whether all elements are Truthy. + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + True, because nonzero integers are considered True. + + >>> bpd.Index([1, 2, 3]).all() + True + + False, because 0 is considered False. + + >>> bpd.Index([0, 1, 2]).all() + False + + Args: + Returns: - bool: A single element array-like may be converted to bool. + bool: + A single element array-like may be converted to bool. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) def any(self) -> bool: """Return whether any element is Truthy. + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> index = bpd.Index([0, 1, 2]) + >>> index.any() + True + + >>> index = bpd.Index([0, 0, 0]) + >>> index.any() + False + Returns: - bool: A single element array-like may be converted to bool. + bool: + A single element array-like may be converted to bool. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) From b6bb657d95b6ddb5735c9a251fc6b7d6df2a16fb Mon Sep 17 00:00:00 2001 From: Arwa Date: Fri, 15 Nov 2024 16:37:29 -0600 Subject: [PATCH 04/15] update docstrings --- bigframes/core/indexes/base.py | 7 - .../pandas/core/indexes/base.py | 290 ++++++++++++++++-- 2 files changed, 266 insertions(+), 31 deletions(-) diff --git a/bigframes/core/indexes/base.py b/bigframes/core/indexes/base.py index a8445835dd..516d5ab639 100644 --- a/bigframes/core/indexes/base.py +++ b/bigframes/core/indexes/base.py @@ -175,7 +175,6 @@ def dtypes(self) -> pandas.Series: @property def size(self) -> int: - """Returns the size of the Index.""" return self.shape[0] @property @@ -186,12 +185,6 @@ def empty(self) -> bool: @property @validations.requires_ordering() def is_monotonic_increasing(self) -> bool: - """ - Return a boolean if the values are equal or increasing. - - Returns: - bool - """ return typing.cast( bool, self._block.is_monotonic_increasing(self._block.index_columns), diff --git a/third_party/bigframes_vendored/pandas/core/indexes/base.py b/third_party/bigframes_vendored/pandas/core/indexes/base.py index e867867e7c..6a9b7f5b85 100644 --- a/third_party/bigframes_vendored/pandas/core/indexes/base.py +++ b/third_party/bigframes_vendored/pandas/core/indexes/base.py @@ -76,7 +76,7 @@ def shape(self): >>> import bigframes.pandas as bpd >>> bpd.options.display.progress_bar = None - >>> idx = pd.Index([1, 2, 3]) + >>> idx = bpd.Index([1, 2, 3]) >>> idx Index([1, 2, 3], dtype='Int64') @@ -151,16 +151,6 @@ def has_duplicates(self) -> bool: >>> idx.has_duplicates False - >>> idx = pd.Index(["Watermelon", "Orange", "Apple", - ... "Watermelon"]).astype("category") - >>> idx.has_duplicates - True - - >>> idx = pd.Index(["Orange", "Apple", - ... "Watermelon"]).astype("category") - >>> idx.has_duplicates - False - Returns: bool: True if the Index has duplicate values, otherwise False. @@ -212,6 +202,10 @@ def T(self) -> Index: dtype: string >>> s.T + 0 Ant + 1 Bear + 2 Cow + dtype: string For Index: @@ -220,6 +214,7 @@ def T(self) -> Index: Index([1, 2, 3], dtype='Int64') Returns: + bigframes.pandas.Index """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -237,7 +232,7 @@ def copy( >>> import bigframes.pandas as bpd >>> bpd.options.display.progress_bar = None - >>> idx = pd.Index(['a', 'b', 'c']) + >>> idx = bpd.Index(['a', 'b', 'c']) >>> new_idx = idx.copy() >>> idx is new_idx False @@ -247,7 +242,7 @@ def copy( Set name for new object. Returns: - Index: + bigframes.pandas.Index: Index reference to new object, which is a copy of this object. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -320,6 +315,8 @@ def get_level_values(self, level) -> Index: >>> idx Index(['a', 'b', 'c'], dtype='string') + Get level values by supplying level as integer: + >>> idx.get_level_values(0) Index(['a', 'b', 'c'], dtype='string') @@ -328,7 +325,7 @@ def get_level_values(self, level) -> Index: It is either the integer position or the name of the level. Returns: - Index: + bigframes.pandas.Index: Calling object, as there is only one level in the Index. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -344,7 +341,7 @@ def to_series(self): >>> import bigframes.pandas as bpd >>> bpd.options.display.progress_bar = None - >>> idx = pd.Index(['Ant', 'Bear', 'Cow'], name='animal') + >>> idx = bpd.Index(['Ant', 'Bear', 'Cow'], name='animal') By default, the original index and original name is reused. @@ -393,12 +390,40 @@ def isin(self, values): passed set of values. The length of the returned boolean array matches the length of the index. + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> idx = bpd.Index([1,2,3]) + >>> idx + Index([1, 2, 3], dtype='Int64') + + Check whether each index value in a list of values. + + >>> idx.isin([1, 4]) + array([ True, False, False]) + + >>> midx = bpd.MultiIndex.from_arrays([[1,2,3], + ... ['red', 'blue', 'green']], + ... names=('number', 'color')) + >>> midx + MultiIndex([(1, 'red'), + (2, 'blue'), + (3, 'green')], + names=['number', 'color']) + Args: values (set or list-like): Sought values. Returns: - Series: Series of boolean values. + bigframes.pandas.Series: + Series of boolean values. + + Raises: + TypeError: + If object passed to ``isin()`` is not a list-like """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -420,8 +445,6 @@ def all(self) -> bool: >>> bpd.Index([0, 1, 2]).all() False - Args: - Returns: bool: A single element array-like may be converted to bool. @@ -453,6 +476,20 @@ def any(self) -> bool: def min(self): """Return the minimum value of the Index. + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> idx = bpd.Index([3, 2, 1]) + >>> idx.min() + 1 + + >>> idx = bpd.Index(['c', 'b', 'a']) + >>> idx.min() + 'a' + + Returns: scalar: Minimum value. """ @@ -461,6 +498,19 @@ def min(self): def max(self): """Return the maximum value of the Index. + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> idx = bpd.Index([3, 2, 1]) + >>> idx.max() + 3 + + >>> idx = bpd.Index(['c', 'b', 'a']) + >>>> idx.max() + 'c' + Returns: scalar: Maximum value. """ @@ -473,6 +523,29 @@ def argmin(self) -> int: If the minimum is achieved in multiple locations, the first row position is returned. + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> s = pd.Series({'Corn Flakes': 100.0, 'Almond Delight': 110.0, + ... 'Cinnamon Toast Crunch': 120.0, 'Cocoa Puff': 110.0}) + >>> s + Corn Flakes 100.0 + Almond Delight 110.0 + Cinnamon Toast Crunch 120.0 + Cocoa Puff 110.0 + dtype: Float64 + + >>> s.argmax() + 2 + + >>> s.argmin() + 0 + + The maximum cereal calories is the third element and the minimum + cereal calories is the first element, since series is zero-indexed. + Returns: int: Row position of the minimum value. """ @@ -485,6 +558,29 @@ def argmax(self) -> int: If the maximum is achieved in multiple locations, the first row position is returned. + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> s = pd.Series({'Corn Flakes': 100.0, 'Almond Delight': 110.0, + ... 'Cinnamon Toast Crunch': 120.0, 'Cocoa Puff': 110.0}) + >>> s + Corn Flakes 100.0 + Almond Delight 110.0 + Cinnamon Toast Crunch 120.0 + Cocoa Puff 110.0 + dtype: Float64 + + >>> s.argmax() + 2 + + >>> s.argmin() + 0 + + The maximum cereal calories is the third element and the minimum + cereal calories is the first element, since series is zero-indexed. + Returns: int: Row position of the maximum value. """ @@ -495,8 +591,26 @@ def nunique(self) -> int: Excludes NA values by default. + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> s = bpd.Series([1, 3, 5, 7, 7]) + >>> s + 0 1 + 1 3 + 2 5 + 3 7 + 4 7 + dtype: Int64 + + >>> s.nunique() + 4 + Returns: - int + int: + Number of unique elements """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -509,6 +623,20 @@ def sort_values( Return a sorted copy of the index, and optionally return the indices that sorted the index itself. + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> idx = bpd.Index([10, 100, 1, 1000]) + >>> idx + Index([10, 100, 1, 1000], dtype='Int64') + + Sort values in ascending order (default behavior). + + >>> idx.sort_values() + Index([1, 10, 100, 1000], dtype='Int64') + Args: ascending (bool, default True): Should the index values be sorted in an ascending order. @@ -518,6 +646,10 @@ def sort_values( Returns: pandas.Index: Sorted copy of the index. + + Raises: + ValueError: + If ``no_position`` is not one of ``first`` or ``last`` """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -535,6 +667,43 @@ def value_counts( first element is the most frequently-occurring element. Excludes NA values by default. + **Examples:** + + >>> import bigframes.pandas as bpd + >>> import numpy as np + >>> bpd.options.display.progress_bar = None + + >>> index = pd.Index([3, 1, 2, 3, 4, np.nan]) + >>> index.value_counts() + 3.0 2 + 1.0 1 + 2.0 1 + 4.0 1 + Name: count, dtype: Int64 + + With normalize set to True, returns the relative frequency by + dividing all values by the sum of values. + + >>> s = bpd.Series([3, 1, 2, 3, 4, np.nan]) + >>> s.value_counts(normalize=True) + 3.0 0.4 + 1.0 0.2 + 2.0 0.2 + 4.0 0.2 + Name: proportion, dtype: Float64 + + dropna + + With dropna set to False we can also see NaN index values. + + >>> s.value_counts(dropna=False) + 3.0 2 + 1.0 1 + 2.0 1 + 4.0 1 + 1 + Name: count, dtype: Int64 + Args: normalize (bool, default False): If True, then the object returned will contain the relative @@ -547,7 +716,7 @@ def value_counts( Don't include counts of NaN. Returns: - Series + bigframe.pandas.Series """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -555,13 +724,23 @@ def fillna(self, value) -> Index: """ Fill NA/NaN values with the specified value. + **Examples:** + + >>> import bigframes.pandas as bpd + >>> import numpy as np + >>> bpd.options.display.progress_bar = None + + >>> idx = bpd.Index([np.nan, np.nan, 3]) + >>> idx.fillna(0) + Index([0.0, 0.0, 3.0], dtype='Float64') + Args: value (scalar): Scalar value to use to fill holes (e.g. 0). This value cannot be a list-likes. Returns: - Index + bigframes.pandas.Index """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -572,12 +751,26 @@ def rename(self, name) -> Index: Able to set new names without level. Defaults to returning new index. Length of names must match number of levels in MultiIndex. + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> idx = bpd.Index(['A', 'C', 'A', 'B'], name='score') + >>> idx.rename('grade') + Index(['A', 'C', 'A', 'B'], dtype='string', name='grade') + Args: name (label or list of labels): Name(s) to set. Returns: - Index: The same type as the caller. + bigframes.pandas.Index: + The same type as the caller. + + Raises: + ValueError: + If ``name`` is not the same length as levels """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -585,6 +778,15 @@ def drop(self, labels) -> Index: """ Make new Index with passed list of labels deleted. + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> idx = bpd.Index(['a', 'b', 'c']) + >>> idx.drop(['a']) + Index(['b', 'c'], dtype='string') + Args: labels (array-like or scalar): @@ -596,13 +798,26 @@ def drop(self, labels) -> Index: def dropna(self, how: typing.Literal["all", "any"] = "any"): """Return Index without NA/NaN values. + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + >>> idx = bpd.Index([1, np.nan, 3]) + >>> idx.dropna() + Index([1.0, 3.0], dtype='Float64') + Args: how ({'any', 'all'}, default 'any'): If the Index is a MultiIndex, drop the value when any or all levels are NaN. Returns: - Index + bigframes.pandas.Index + + Raises: + ValueError: + If ``how`` is not ``any`` or ``all`` """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -610,6 +825,33 @@ def drop_duplicates(self, *, keep: str = "first"): """ Return Index with duplicate values removed. + **Examples:** + + >>> import bigframes.pandas as bpd + >>> bpd.options.display.progress_bar = None + + Generate an pandas.Index with duplicate values. + + >>> idx = bpd.Index(['lama', 'cow', 'lama', 'beetle', 'lama', 'hippo']) + + The keep parameter controls which duplicate values are removed. + The value ``first`` keeps the first occurrence for each set of + duplicated entries. The default value of keep is ``first``. + + >>> idx.drop_duplicates(keep='first') + Index(['lama', 'cow', 'beetle', 'hippo'], dtype='string') + + The value ``last`` keeps the last occurrence for each set of + duplicated entries. + + >>> idx.drop_duplicates(keep='last') + Index(['cow', 'beetle', 'lama', 'hippo'], dtype='string') + + The value ``False`` discards all sets of duplicated entries. + + >>> idx.drop_duplicates(keep=False) + Index(['cow', 'beetle', 'hippo'], dtype='string') + Args: keep ({'first', 'last', ``False``}, default 'first'): One of: @@ -618,7 +860,7 @@ def drop_duplicates(self, *, keep: str = "first"): ``False`` : Drop all duplicates. Returns: - Index + bigframes.pandas.Index """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) From a35f2b8b5345326c6a85bddabead50c6a615604b Mon Sep 17 00:00:00 2001 From: Arwa Date: Wed, 20 Nov 2024 12:56:48 -0600 Subject: [PATCH 05/15] update docs --- .../pandas/core/indexes/base.py | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/third_party/bigframes_vendored/pandas/core/indexes/base.py b/third_party/bigframes_vendored/pandas/core/indexes/base.py index 6a9b7f5b85..e66d009831 100644 --- a/third_party/bigframes_vendored/pandas/core/indexes/base.py +++ b/third_party/bigframes_vendored/pandas/core/indexes/base.py @@ -48,6 +48,9 @@ def name(self): def values(self): """Return an array representing the data in the Index. + .. warning: + We recommend using ``Index.array`` or ``Index.to_numpy()``, depending on whether you need a reference to the underlying data or a NumPy array. + **Examples:** >>> import bigframes.pandas as bpd @@ -85,7 +88,7 @@ def shape(self): Returns: Tuple[int]: - A tuple of int representing the shape. + A Tuple of integers representing the shape. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -153,7 +156,7 @@ def has_duplicates(self) -> bool: Returns: bool: - True if the Index has duplicate values, otherwise False. + Whether or not the Index has duplicate values. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -214,7 +217,8 @@ def T(self) -> Index: Index([1, 2, 3], dtype='Int64') Returns: - bigframes.pandas.Index + bigframes.pandas.Index: + Index """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -247,16 +251,6 @@ def copy( """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) - def transpose(self) -> Index: - """ - Return the transpose, which is by definition self. - - Returns: - bigframes.pandas.Index - An Index. - """ - raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) - def astype(self, dtype): """Create an Index with values cast to dtypes. @@ -296,6 +290,13 @@ def astype(self, dtype): Returns: Index: Index with values cast to specified dtype. + + Raises: + ValueError: + If ``errors`` is not one of ``raise``. + + TypeError: + MultiIndex with more than 1 level does not support ``astype``. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -448,6 +449,10 @@ def all(self) -> bool: Returns: bool: A single element array-like may be converted to bool. + + Raises: + TypeError: + MultiIndex with more than 1 level does not support ``all``. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -470,6 +475,10 @@ def any(self) -> bool: Returns: bool: A single element array-like may be converted to bool. + + Raises: + TypeError: + MultiIndex with more than 1 level does not support ``any``. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -649,7 +658,7 @@ def sort_values( Raises: ValueError: - If ``no_position`` is not one of ``first`` or ``last`` + If ``no_position`` is not one of ``first`` or ``last``. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -770,7 +779,7 @@ def rename(self, name) -> Index: Raises: ValueError: - If ``name`` is not the same length as levels + If ``name`` is not the same length as levels. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) From 0f24b5cd59e973927fdbbdb4edb75acd6e46b187 Mon Sep 17 00:00:00 2001 From: Arwa Date: Thu, 21 Nov 2024 12:14:32 -0600 Subject: [PATCH 06/15] update docstrings --- bigframes/core/indexes/base.py | 1 - .../pandas/core/indexes/base.py | 39 ++++++++++++++----- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/bigframes/core/indexes/base.py b/bigframes/core/indexes/base.py index 516d5ab639..890f071028 100644 --- a/bigframes/core/indexes/base.py +++ b/bigframes/core/indexes/base.py @@ -134,7 +134,6 @@ def name(self, value: blocks.Label): @property def names(self) -> typing.Sequence[blocks.Label]: - """Returns the names of the Index.""" return self._block._index_labels @names.setter diff --git a/third_party/bigframes_vendored/pandas/core/indexes/base.py b/third_party/bigframes_vendored/pandas/core/indexes/base.py index e66d009831..510354a359 100644 --- a/third_party/bigframes_vendored/pandas/core/indexes/base.py +++ b/third_party/bigframes_vendored/pandas/core/indexes/base.py @@ -251,6 +251,15 @@ def copy( """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def transpose(self) -> Index: + """ + Return the transpose, which is by definition self. + + Returns: + bigframes.pandas.Index + """ + raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) + def astype(self, dtype): """Create an Index with values cast to dtypes. @@ -262,7 +271,7 @@ def astype(self, dtype): >>> import bigframes.pandas as bpd >>> bpd.options.display.progress_bar = None - >>> idx = pd.Index([1, 2, 3]) + >>> idx = bpd.Index([1, 2, 3]) >>> idx Index([1, 2, 3], dtype='Int64') @@ -500,7 +509,8 @@ def min(self): Returns: - scalar: Minimum value. + scalar: + Minimum value. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -521,7 +531,8 @@ def max(self): 'c' Returns: - scalar: Maximum value. + scalar: + Maximum value. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -537,7 +548,9 @@ def argmin(self) -> int: >>> import bigframes.pandas as bpd >>> bpd.options.display.progress_bar = None - >>> s = pd.Series({'Corn Flakes': 100.0, 'Almond Delight': 110.0, + Consider dataset containing cereal calories + + >>> s = bpd.Series({'Corn Flakes': 100.0, 'Almond Delight': 110.0, ... 'Cinnamon Toast Crunch': 120.0, 'Cocoa Puff': 110.0}) >>> s Corn Flakes 100.0 @@ -556,7 +569,8 @@ def argmin(self) -> int: cereal calories is the first element, since series is zero-indexed. Returns: - int: Row position of the minimum value. + int: + Row position of the minimum value. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -569,10 +583,12 @@ def argmax(self) -> int: **Examples:** + Consider dataset containing cereal calories + >>> import bigframes.pandas as bpd >>> bpd.options.display.progress_bar = None - >>> s = pd.Series({'Corn Flakes': 100.0, 'Almond Delight': 110.0, + >>> s = bpd.Series({'Corn Flakes': 100.0, 'Almond Delight': 110.0, ... 'Cinnamon Toast Crunch': 120.0, 'Cocoa Puff': 110.0}) >>> s Corn Flakes 100.0 @@ -591,7 +607,8 @@ def argmax(self) -> int: cereal calories is the first element, since series is zero-indexed. Returns: - int: Row position of the maximum value. + int: + Row position of the maximum value. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -682,7 +699,7 @@ def value_counts( >>> import numpy as np >>> bpd.options.display.progress_bar = None - >>> index = pd.Index([3, 1, 2, 3, 4, np.nan]) + >>> index = bpd.Index([3, 1, 2, 3, 4, np.nan]) >>> index.value_counts() 3.0 2 1.0 1 @@ -725,7 +742,7 @@ def value_counts( Don't include counts of NaN. Returns: - bigframe.pandas.Series + bigframes.pandas.Series """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -750,6 +767,10 @@ def fillna(self, value) -> Index: Returns: bigframes.pandas.Index + + Raises: + TypeError: + MultiIndex with more than 1 level does not support ``fillna``. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) From 6cfa9204bb7b01aa35e36087dd99ee92732253d5 Mon Sep 17 00:00:00 2001 From: Arwa Date: Thu, 21 Nov 2024 14:44:26 -0600 Subject: [PATCH 07/15] fix failing doc test --- .../bigframes_vendored/pandas/core/indexes/base.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/third_party/bigframes_vendored/pandas/core/indexes/base.py b/third_party/bigframes_vendored/pandas/core/indexes/base.py index 510354a359..0696c7c0ed 100644 --- a/third_party/bigframes_vendored/pandas/core/indexes/base.py +++ b/third_party/bigframes_vendored/pandas/core/indexes/base.py @@ -48,9 +48,6 @@ def name(self): def values(self): """Return an array representing the data in the Index. - .. warning: - We recommend using ``Index.array`` or ``Index.to_numpy()``, depending on whether you need a reference to the underlying data or a NumPy array. - **Examples:** >>> import bigframes.pandas as bpd @@ -104,12 +101,12 @@ def nlevels(self) -> int: >>> mi = bpd.MultiIndex.from_arrays([['a'], ['b'], ['c']]) >>> mi MultiIndex([('a', 'b', 'c')], - ... ) - >>> mi.nlevels - 3 + ... ) + >>> mi.nlevels + 3 Returns: - Int: + int: Number of levels. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) From 7e70ceb3b6b3a713966aab02b4de94dee61ac425 Mon Sep 17 00:00:00 2001 From: Arwa Date: Thu, 21 Nov 2024 16:21:22 -0600 Subject: [PATCH 08/15] fix docs indentation --- .../pandas/core/indexes/base.py | 56 +++++++++---------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/third_party/bigframes_vendored/pandas/core/indexes/base.py b/third_party/bigframes_vendored/pandas/core/indexes/base.py index 0696c7c0ed..30fe896a41 100644 --- a/third_party/bigframes_vendored/pandas/core/indexes/base.py +++ b/third_party/bigframes_vendored/pandas/core/indexes/base.py @@ -83,9 +83,9 @@ def shape(self): >>> idx.shape (3,) - Returns: - Tuple[int]: - A Tuple of integers representing the shape. + Returns: + Tuple[int]: + A Tuple of integers representing the shape. """ raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) @@ -295,12 +295,11 @@ def astype(self, dtype): If 'null', will assign null value if value fails cast Returns: - Index: Index with values cast to specified dtype. + bigframes.pandas.Index: Index with values cast to specified dtype. Raises: ValueError: If ``errors`` is not one of ``raise``. - TypeError: MultiIndex with more than 1 level does not support ``astype``. """ @@ -322,7 +321,7 @@ def get_level_values(self, level) -> Index: >>> idx Index(['a', 'b', 'c'], dtype='string') - Get level values by supplying level as integer: + Get level values by supplying level as integer: >>> idx.get_level_values(0) Index(['a', 'b', 'c'], dtype='string') @@ -350,7 +349,7 @@ def to_series(self): >>> idx = bpd.Index(['Ant', 'Bear', 'Cow'], name='animal') - By default, the original index and original name is reused. + By default, the original index and original name is reused. >>> idx.to_series() animal @@ -359,7 +358,7 @@ def to_series(self): Cow Cow Name: animal, dtype: string - To enforce a new index, specify new labels to index: + To enforce a new index, specify new labels to index: >>> idx.to_series(index=[0, 1, 2]) 0 Ant @@ -367,7 +366,7 @@ def to_series(self): 2 Cow Name: animal, dtype: string - To override the name of the resulting column, specify name: + To override the name of the resulting column, specify name: >>> idx.to_series(name='zoo') animal @@ -406,7 +405,7 @@ def isin(self, values): >>> idx Index([1, 2, 3], dtype='Int64') - Check whether each index value in a list of values. + Check whether each index value in a list of values. >>> idx.isin([1, 4]) array([ True, False, False]) @@ -442,7 +441,7 @@ def all(self) -> bool: >>> import bigframes.pandas as bpd >>> bpd.options.display.progress_bar = None - True, because nonzero integers are considered True. + True, because nonzero integers are considered True. >>> bpd.Index([1, 2, 3]).all() True @@ -504,7 +503,6 @@ def min(self): >>> idx.min() 'a' - Returns: scalar: Minimum value. @@ -545,7 +543,7 @@ def argmin(self) -> int: >>> import bigframes.pandas as bpd >>> bpd.options.display.progress_bar = None - Consider dataset containing cereal calories + Consider dataset containing cereal calories >>> s = bpd.Series({'Corn Flakes': 100.0, 'Almond Delight': 110.0, ... 'Cinnamon Toast Crunch': 120.0, 'Cocoa Puff': 110.0}) @@ -562,8 +560,8 @@ def argmin(self) -> int: >>> s.argmin() 0 - The maximum cereal calories is the third element and the minimum - cereal calories is the first element, since series is zero-indexed. + The maximum cereal calories is the third element and the minimum + cereal calories is the first element, since series is zero-indexed. Returns: int: @@ -580,7 +578,7 @@ def argmax(self) -> int: **Examples:** - Consider dataset containing cereal calories + Consider dataset containing cereal calories >>> import bigframes.pandas as bpd >>> bpd.options.display.progress_bar = None @@ -600,8 +598,8 @@ def argmax(self) -> int: >>> s.argmin() 0 - The maximum cereal calories is the third element and the minimum - cereal calories is the first element, since series is zero-indexed. + The maximum cereal calories is the third element and the minimum + cereal calories is the first element, since series is zero-indexed. Returns: int: @@ -655,7 +653,7 @@ def sort_values( >>> idx Index([10, 100, 1, 1000], dtype='Int64') - Sort values in ascending order (default behavior). + Sort values in ascending order (default behavior). >>> idx.sort_values() Index([1, 10, 100, 1000], dtype='Int64') @@ -704,8 +702,8 @@ def value_counts( 4.0 1 Name: count, dtype: Int64 - With normalize set to True, returns the relative frequency by - dividing all values by the sum of values. + With normalize set to True, returns the relative frequency by + dividing all values by the sum of values. >>> s = bpd.Series([3, 1, 2, 3, 4, np.nan]) >>> s.value_counts(normalize=True) @@ -715,9 +713,9 @@ def value_counts( 4.0 0.2 Name: proportion, dtype: Float64 - dropna + ``dropna`` - With dropna set to False we can also see NaN index values. + With dropna set to False we can also see NaN index values. >>> s.value_counts(dropna=False) 3.0 2 @@ -861,20 +859,20 @@ def drop_duplicates(self, *, keep: str = "first"): >>> idx = bpd.Index(['lama', 'cow', 'lama', 'beetle', 'lama', 'hippo']) - The keep parameter controls which duplicate values are removed. - The value ``first`` keeps the first occurrence for each set of - duplicated entries. The default value of keep is ``first``. + The keep parameter controls which duplicate values are removed. + The value ``first`` keeps the first occurrence for each set of + duplicated entries. The default value of keep is ``first``. >>> idx.drop_duplicates(keep='first') Index(['lama', 'cow', 'beetle', 'hippo'], dtype='string') - The value ``last`` keeps the last occurrence for each set of - duplicated entries. + The value ``last`` keeps the last occurrence for each set of + duplicated entries. >>> idx.drop_duplicates(keep='last') Index(['cow', 'beetle', 'lama', 'hippo'], dtype='string') - The value ``False`` discards all sets of duplicated entries. + The value ``False`` discards all sets of duplicated entries. >>> idx.drop_duplicates(keep=False) Index(['cow', 'beetle', 'hippo'], dtype='string') From b796b2b753b1528fa8f4ccd5f76d0a2c85d08919 Mon Sep 17 00:00:00 2001 From: Arwa Date: Fri, 22 Nov 2024 16:25:07 -0600 Subject: [PATCH 09/15] fix indentation error --- third_party/bigframes_vendored/pandas/core/indexes/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/third_party/bigframes_vendored/pandas/core/indexes/base.py b/third_party/bigframes_vendored/pandas/core/indexes/base.py index 30fe896a41..89a7063eca 100644 --- a/third_party/bigframes_vendored/pandas/core/indexes/base.py +++ b/third_party/bigframes_vendored/pandas/core/indexes/base.py @@ -411,8 +411,8 @@ def isin(self, values): array([ True, False, False]) >>> midx = bpd.MultiIndex.from_arrays([[1,2,3], - ... ['red', 'blue', 'green']], - ... names=('number', 'color')) + ... ['red', 'blue', 'green']], + ... names=('number', 'color')) >>> midx MultiIndex([(1, 'red'), (2, 'blue'), From f6b00a7f0c1a3a1bbc92d987595836da126bd7b6 Mon Sep 17 00:00:00 2001 From: Arwa Date: Fri, 22 Nov 2024 17:02:21 -0600 Subject: [PATCH 10/15] fix doctest error --- third_party/bigframes_vendored/pandas/core/indexes/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/bigframes_vendored/pandas/core/indexes/base.py b/third_party/bigframes_vendored/pandas/core/indexes/base.py index 89a7063eca..7d7b319b20 100644 --- a/third_party/bigframes_vendored/pandas/core/indexes/base.py +++ b/third_party/bigframes_vendored/pandas/core/indexes/base.py @@ -522,7 +522,7 @@ def max(self): 3 >>> idx = bpd.Index(['c', 'b', 'a']) - >>>> idx.max() + >>> idx.max() 'c' Returns: From aaf224e817b7a99798d0c8224ab73542dd26bb73 Mon Sep 17 00:00:00 2001 From: Arwa Date: Mon, 25 Nov 2024 10:11:39 -0600 Subject: [PATCH 11/15] fix doctest error --- third_party/bigframes_vendored/pandas/core/indexes/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/third_party/bigframes_vendored/pandas/core/indexes/base.py b/third_party/bigframes_vendored/pandas/core/indexes/base.py index 7d7b319b20..addb594d93 100644 --- a/third_party/bigframes_vendored/pandas/core/indexes/base.py +++ b/third_party/bigframes_vendored/pandas/core/indexes/base.py @@ -546,7 +546,7 @@ def argmin(self) -> int: Consider dataset containing cereal calories >>> s = bpd.Series({'Corn Flakes': 100.0, 'Almond Delight': 110.0, - ... 'Cinnamon Toast Crunch': 120.0, 'Cocoa Puff': 110.0}) + ... 'Cinnamon Toast Crunch': 120.0, 'Cocoa Puff': 110.0}) >>> s Corn Flakes 100.0 Almond Delight 110.0 @@ -584,7 +584,7 @@ def argmax(self) -> int: >>> bpd.options.display.progress_bar = None >>> s = bpd.Series({'Corn Flakes': 100.0, 'Almond Delight': 110.0, - ... 'Cinnamon Toast Crunch': 120.0, 'Cocoa Puff': 110.0}) + ... 'Cinnamon Toast Crunch': 120.0, 'Cocoa Puff': 110.0}) >>> s Corn Flakes 100.0 Almond Delight 110.0 From 78c4d0bff7bada0c04fd306761886f998365bd61 Mon Sep 17 00:00:00 2001 From: Arwa Date: Mon, 25 Nov 2024 11:30:32 -0600 Subject: [PATCH 12/15] fix errors --- .../pandas/core/indexes/base.py | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/third_party/bigframes_vendored/pandas/core/indexes/base.py b/third_party/bigframes_vendored/pandas/core/indexes/base.py index addb594d93..532d30c19a 100644 --- a/third_party/bigframes_vendored/pandas/core/indexes/base.py +++ b/third_party/bigframes_vendored/pandas/core/indexes/base.py @@ -34,6 +34,7 @@ def name(self): >>> bpd.options.display.progress_bar = None >>> idx = bpd.Index([1, 2, 3], name='x') + >>> idx Index([1, 2, 3], dtype='Int64', name='x') >>> idx.name 'x' @@ -144,11 +145,11 @@ def has_duplicates(self) -> bool: >>> bpd.options.display.progress_bar = None >>> idx = bpd.Index([1, 5, 7, 7]) - >>> idx.has_duplicates + >>> bool(idx.has_duplicates) True >>> idx = bpd.Index([1, 5, 7]) - >>> idx.has_duplicates + >>> bool(idx.has_duplicates) False Returns: @@ -408,7 +409,7 @@ def isin(self, values): Check whether each index value in a list of values. >>> idx.isin([1, 4]) - array([ True, False, False]) + Index([True, False, False], dtype='boolean') >>> midx = bpd.MultiIndex.from_arrays([[1,2,3], ... ['red', 'blue', 'green']], @@ -443,12 +444,12 @@ def all(self) -> bool: True, because nonzero integers are considered True. - >>> bpd.Index([1, 2, 3]).all() + >>> bool(bpd.Index([1, 2, 3]).all()) True False, because 0 is considered False. - >>> bpd.Index([0, 1, 2]).all() + >>> bool(bpd.Index([0, 1, 2]).all()) False Returns: @@ -470,11 +471,11 @@ def any(self) -> bool: >>> bpd.options.display.progress_bar = None >>> index = bpd.Index([0, 1, 2]) - >>> index.any() + >>> bool(index.any()) True >>> index = bpd.Index([0, 0, 0]) - >>> index.any() + >>> bool(index.any()) False Returns: @@ -496,7 +497,7 @@ def min(self): >>> bpd.options.display.progress_bar = None >>> idx = bpd.Index([3, 2, 1]) - >>> idx.min() + >>> int(idx.min()) 1 >>> idx = bpd.Index(['c', 'b', 'a']) @@ -518,7 +519,7 @@ def max(self): >>> bpd.options.display.progress_bar = None >>> idx = bpd.Index([3, 2, 1]) - >>> idx.max() + >>> int(idx.max()) 3 >>> idx = bpd.Index(['c', 'b', 'a']) @@ -826,6 +827,7 @@ def dropna(self, how: typing.Literal["all", "any"] = "any"): **Examples:** >>> import bigframes.pandas as bpd + >>> import Numpy as np >>> bpd.options.display.progress_bar = None >>> idx = bpd.Index([1, np.nan, 3]) From 9dca9297905a598ecf69a3bdeb6923719fbef94d Mon Sep 17 00:00:00 2001 From: Arwa Date: Mon, 25 Nov 2024 11:57:13 -0600 Subject: [PATCH 13/15] fix errors --- .../bigframes_vendored/pandas/core/indexes/base.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/third_party/bigframes_vendored/pandas/core/indexes/base.py b/third_party/bigframes_vendored/pandas/core/indexes/base.py index 532d30c19a..9b83bc7432 100644 --- a/third_party/bigframes_vendored/pandas/core/indexes/base.py +++ b/third_party/bigframes_vendored/pandas/core/indexes/base.py @@ -102,7 +102,7 @@ def nlevels(self) -> int: >>> mi = bpd.MultiIndex.from_arrays([['a'], ['b'], ['c']]) >>> mi MultiIndex([('a', 'b', 'c')], - ... ) + ... ) >>> mi.nlevels 3 @@ -555,10 +555,10 @@ def argmin(self) -> int: Cocoa Puff 110.0 dtype: Float64 - >>> s.argmax() + >>> int(s.argmax()) 2 - >>> s.argmin() + >>> int(s.argmin()) 0 The maximum cereal calories is the third element and the minimum @@ -593,10 +593,10 @@ def argmax(self) -> int: Cocoa Puff 110.0 dtype: Float64 - >>> s.argmax() + >>> int(s.argmax()) 2 - >>> s.argmin() + >>> int(s.argmin()) 0 The maximum cereal calories is the third element and the minimum @@ -627,7 +627,7 @@ def nunique(self) -> int: 4 7 dtype: Int64 - >>> s.nunique() + >>> int(s.nunique()) 4 Returns: @@ -827,7 +827,7 @@ def dropna(self, how: typing.Literal["all", "any"] = "any"): **Examples:** >>> import bigframes.pandas as bpd - >>> import Numpy as np + >>> import numpy as np >>> bpd.options.display.progress_bar = None >>> idx = bpd.Index([1, np.nan, 3]) From d5e39f479b98524c8d03c21385914684304562e1 Mon Sep 17 00:00:00 2001 From: Arwa Date: Tue, 26 Nov 2024 09:45:33 -0600 Subject: [PATCH 14/15] fix failing doctest --- third_party/bigframes_vendored/pandas/core/indexes/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/bigframes_vendored/pandas/core/indexes/base.py b/third_party/bigframes_vendored/pandas/core/indexes/base.py index 9b83bc7432..59a9bca087 100644 --- a/third_party/bigframes_vendored/pandas/core/indexes/base.py +++ b/third_party/bigframes_vendored/pandas/core/indexes/base.py @@ -102,7 +102,7 @@ def nlevels(self) -> int: >>> mi = bpd.MultiIndex.from_arrays([['a'], ['b'], ['c']]) >>> mi MultiIndex([('a', 'b', 'c')], - ... ) + ) >>> mi.nlevels 3 From fd90334b4323285d05a0f692837e8bce7023f403 Mon Sep 17 00:00:00 2001 From: Arwa Date: Wed, 27 Nov 2024 09:45:44 -0600 Subject: [PATCH 15/15] remove .name docstring --- .../pandas/core/indexes/base.py | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/third_party/bigframes_vendored/pandas/core/indexes/base.py b/third_party/bigframes_vendored/pandas/core/indexes/base.py index 59a9bca087..e5666e99c6 100644 --- a/third_party/bigframes_vendored/pandas/core/indexes/base.py +++ b/third_party/bigframes_vendored/pandas/core/indexes/base.py @@ -24,27 +24,6 @@ class Index: a default session is used. """ - @property - def name(self): - """Returns Index name. - - **Examples:** - - >>> import bigframes.pandas as bpd - >>> bpd.options.display.progress_bar = None - - >>> idx = bpd.Index([1, 2, 3], name='x') - >>> idx - Index([1, 2, 3], dtype='Int64', name='x') - >>> idx.name - 'x' - - Returns: - blocks.Label: - Index or MultiIndex name - """ - raise NotImplementedError(constants.ABSTRACT_METHOD_ERROR_MESSAGE) - @property def values(self): """Return an array representing the data in the Index.