diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 9ef8a7395d30e..7678e1e975d1a 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -64,13 +64,10 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then MSG='Partially validate docstrings (EX01)' ; echo $MSG $BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX01 --ignore_functions \ pandas.NaT \ - pandas.io.stata.StataReader.value_labels \ - pandas.io.stata.StataReader.variable_labels \ pandas.io.stata.StataWriter.write_file \ pandas.plotting.deregister_matplotlib_converters \ pandas.plotting.register_matplotlib_converters \ pandas.api.extensions.ExtensionArray \ - pandas.arrays.NumpyExtensionArray \ RET=$(($RET + $?)) ; echo $MSG "DONE" fi diff --git a/pandas/core/arrays/numpy_.py b/pandas/core/arrays/numpy_.py index 6d01dfcf6d90b..bb426e931c53c 100644 --- a/pandas/core/arrays/numpy_.py +++ b/pandas/core/arrays/numpy_.py @@ -73,6 +73,13 @@ class NumpyExtensionArray( # type: ignore[misc] Methods ------- None + + Examples + -------- + >>> pd.arrays.NumpyExtensionArray(np.array([0, 1, 2, 3])) + + [0, 1, 2, 3] + Length: 4, dtype: int64 """ # If you're wondering why pd.Series(cls) doesn't put the array in an diff --git a/pandas/io/stata.py b/pandas/io/stata.py index 449e404869d56..2181b33b315ae 100644 --- a/pandas/io/stata.py +++ b/pandas/io/stata.py @@ -2063,6 +2063,22 @@ def variable_labels(self) -> dict[str, str]: Returns ------- dict + + Examples + -------- + >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=["col_1", "col_2"]) + >>> time_stamp = pd.Timestamp(2000, 2, 29, 14, 21) + >>> path = "/My_path/filename.dta" + >>> variable_labels = {"col_1": "This is an example"} + >>> df.to_stata(path, time_stamp=time_stamp, # doctest: +SKIP + ... variable_labels=variable_labels, version=None) # doctest: +SKIP + >>> with pd.io.stata.StataReader(path) as reader: # doctest: +SKIP + ... print(reader.variable_labels()) # doctest: +SKIP + {'index': '', 'col_1': 'This is an example', 'col_2': ''} + >>> pd.read_stata(path) # doctest: +SKIP + index col_1 col_2 + 0 0 1 2 + 1 1 3 4 """ self._ensure_open() return dict(zip(self._varlist, self._variable_labels)) @@ -2074,6 +2090,22 @@ def value_labels(self) -> dict[str, dict[float, str]]: Returns ------- dict + + Examples + -------- + >>> df = pd.DataFrame([[1, 2], [3, 4]], columns=["col_1", "col_2"]) + >>> time_stamp = pd.Timestamp(2000, 2, 29, 14, 21) + >>> path = "/My_path/filename.dta" + >>> value_labels = {"col_1": {3: "x"}} + >>> df.to_stata(path, time_stamp=time_stamp, # doctest: +SKIP + ... value_labels=value_labels, version=None) # doctest: +SKIP + >>> with pd.io.stata.StataReader(path) as reader: # doctest: +SKIP + ... print(reader.value_labels()) # doctest: +SKIP + {'col_1': {3: 'x'}} + >>> pd.read_stata(path) # doctest: +SKIP + index col_1 col_2 + 0 0 1 2 + 1 1 x 4 """ if not self._value_labels_read: self._read_value_labels()