diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 4eecee4be4731..64c5b735fdc8d 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -170,8 +170,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then pandas.Period.asfreq \ pandas.Period.now \ pandas.arrays.PeriodArray \ - pandas.arrays.IntervalArray.from_arrays \ - pandas.arrays.IntervalArray.to_tuples \ pandas.Int8Dtype \ pandas.Int16Dtype \ pandas.Int32Dtype \ @@ -181,8 +179,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then pandas.UInt32Dtype \ pandas.UInt64Dtype \ pandas.NA \ - pandas.Float32Dtype \ - pandas.Float64Dtype \ pandas.CategoricalDtype.categories \ pandas.CategoricalDtype.ordered \ pandas.Categorical.dtype \ @@ -258,9 +254,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then pandas.util.hash_pandas_object \ pandas_object \ pandas.api.interchange.from_dataframe \ - pandas.Index.T \ - pandas.Index.memory_usage \ - pandas.Index.copy \ pandas.Index.drop \ pandas.Index.identical \ pandas.Index.insert \ diff --git a/pandas/core/arrays/floating.py b/pandas/core/arrays/floating.py index c268b25bf4a59..bd3c03f9218d4 100644 --- a/pandas/core/arrays/floating.py +++ b/pandas/core/arrays/floating.py @@ -134,6 +134,20 @@ class FloatingArray(NumericArray): Methods ------- None + +Examples +-------- +For Float32Dtype: + +>>> ser = pd.Series([2.25, pd.NA], dtype=pd.Float32Dtype()) +>>> ser.dtype +Float32Dtype() + +For Float64Dtype: + +>>> ser = pd.Series([2.25, pd.NA], dtype=pd.Float64Dtype()) +>>> ser.dtype +Float64Dtype() """ # create the Dtype diff --git a/pandas/core/arrays/interval.py b/pandas/core/arrays/interval.py index 2303f8334c07c..2842d8267b7c6 100644 --- a/pandas/core/arrays/interval.py +++ b/pandas/core/arrays/interval.py @@ -509,6 +509,8 @@ def from_breaks( "name": "", "examples": textwrap.dedent( """\ + Examples + -------- >>> pd.arrays.IntervalArray.from_arrays([0, 1, 2], [1, 2, 3]) [(0, 1], (1, 2], (2, 3]] @@ -1635,9 +1637,8 @@ def __arrow_array__(self, type=None): return pyarrow.ExtensionArray.from_storage(interval_type, storage_array) - _interval_shared_docs[ - "to_tuples" - ] = """ + _interval_shared_docs["to_tuples"] = textwrap.dedent( + """ Return an %(return_type)s of tuples of the form (left, right). Parameters @@ -1651,9 +1652,27 @@ def __arrow_array__(self, type=None): tuples: %(return_type)s %(examples)s\ """ + ) @Appender( - _interval_shared_docs["to_tuples"] % {"return_type": "ndarray", "examples": ""} + _interval_shared_docs["to_tuples"] + % { + "return_type": "ndarray", + "examples": textwrap.dedent( + """\ + + Examples + -------- + >>> idx = pd.arrays.IntervalArray.from_tuples([(0, 1), (1, 2)]) + >>> idx + + [(0, 1], (1, 2]] + Length: 2, dtype: interval[int64, right] + >>> idx.to_tuples() + array([(0, 1), (1, 2)], dtype=object) + """ + ), + } ) def to_tuples(self, na_tuple: bool = True) -> np.ndarray: tuples = com.asarray_tuplesafe(zip(self._left, self._right)) diff --git a/pandas/core/base.py b/pandas/core/base.py index d939c0d454de8..0d99118d25e96 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -300,6 +300,8 @@ def transpose(self, *args, **kwargs) -> Self: Examples -------- + For Series: + >>> s = pd.Series(['Ant', 'Bear', 'Cow']) >>> s 0 Ant @@ -311,6 +313,12 @@ def transpose(self, *args, **kwargs) -> Self: 1 Bear 2 Cow dtype: object + + For Index: + + >>> idx = pd.Index([1, 2, 3]) + >>> idx.T + Index([1, 2, 3], dtype='int64') """, ) @@ -1088,6 +1096,12 @@ def _memory_usage(self, deep: bool = False) -> int: ----- Memory usage does not include memory consumed by elements that are not components of the array if deep=False or if used on PyPy + + Examples + -------- + >>> idx = pd.Index([1, 2, 3]) + >>> idx.memory_usage() + 24 """ if hasattr(self.array, "memory_usage"): return self.array.memory_usage( # pyright: ignore[reportGeneralTypeIssues] diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index e7d975068dd70..174c6625fb779 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -1221,6 +1221,13 @@ def copy( ----- In most cases, there should be no functional difference from using ``deep``, but if ``deep`` is passed it will attempt to deepcopy. + + Examples + -------- + >>> idx = pd.Index(['a', 'b', 'c']) + >>> new_idx = idx.copy() + >>> idx is new_idx + False """ name = self._validate_names(name=name, deep=deep)[0]