diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 875e328110aaf..4a9e18fb33eaa 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -145,7 +145,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then MSG='Partially validate docstrings (GL08)' ; echo $MSG $BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=GL08 --ignore_functions \ pandas.ExcelFile.book\ - pandas.ExcelFile.sheet_names\ pandas.Index.empty\ pandas.Index.names\ pandas.Index.view\ @@ -153,7 +152,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then pandas.IntervalIndex.length\ pandas.IntervalIndex.mid\ pandas.IntervalIndex.right\ - pandas.MultiIndex.codes\ pandas.Period.freq\ pandas.Period.ordinal\ pandas.PeriodIndex.freq\ diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index c59f756b4e146..119c86770af3e 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -1078,6 +1078,29 @@ def levshape(self) -> Shape: @property def codes(self) -> tuple: + """ + Codes of the MultiIndex. + + Codes are the position of the index value in the list of level values + for each level. + + Returns + ------- + tuple of numpy.ndarray + The codes of the MultiIndex. Each array in the tuple corresponds + to a level in the MultiIndex. + + See Also + -------- + MultiIndex.set_codes : Set new codes on MultiIndex. + + Examples + -------- + >>> arrays = [[1, 1, 2, 2], ["red", "blue", "red", "blue"]] + >>> mi = pd.MultiIndex.from_arrays(arrays, names=("number", "color")) + >>> mi.codes + (array([0, 0, 1, 1], dtype=int8), array([1, 0, 1, 0], dtype=int8)) + """ return self._codes def _set_codes( diff --git a/pandas/io/excel/_base.py b/pandas/io/excel/_base.py index f8d950db6642a..6fa23ef94d200 100644 --- a/pandas/io/excel/_base.py +++ b/pandas/io/excel/_base.py @@ -1630,6 +1630,29 @@ def book(self): @property def sheet_names(self): + """ + Names of the sheets in the document. + + This is particularly useful for loading a specific sheet into a DataFrame when + you do not know the sheet names beforehand. + + Returns + ------- + list of str + List of sheet names in the document. + + See Also + -------- + ExcelFile.parse : Parse a sheet into a DataFrame. + read_excel : Read an Excel file into a pandas DataFrame. If you know the sheet + names, it may be easier to specify them directly to read_excel. + + Examples + -------- + >>> file = pd.ExcelFile("myfile.xlsx") # doctest: +SKIP + >>> file.sheet_names # doctest: +SKIP + ["Sheet1", "Sheet2"] + """ return self._reader.sheet_names def close(self) -> None: