Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions pandas/core/arrays/numpy_.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ class NumpyExtensionArray( # type: ignore[misc]
Methods
-------
None
Examples
--------
>>> pd.arrays.NumpyExtensionArray(np.array([0, 1, 2, 3]))
<NumpyExtensionArray>
[0, 1, 2, 3]
Length: 4, dtype: int64
"""

# If you're wondering why pd.Series(cls) doesn't put the array in an
Expand Down
32 changes: 32 additions & 0 deletions pandas/io/stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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()
Expand Down