Skip to content

DOC: Fixing EX01 - Added examples #54357

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 2, 2023
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
1 change: 0 additions & 1 deletion ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ 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.io.stata.StataWriter.write_file \
pandas.api.extensions.ExtensionArray \
RET=$(($RET + $?)) ; echo $MSG "DONE"

Expand Down
24 changes: 24 additions & 0 deletions pandas/io/stata.py
Original file line number Diff line number Diff line change
Expand Up @@ -2737,6 +2737,30 @@ def _encode_strings(self) -> None:
def write_file(self) -> None:
"""
Export DataFrame object to Stata dta format.

Examples
--------
>>> df = pd.DataFrame({"fully_labelled": [1, 2, 3, 3, 1],
... "partially_labelled": [1.0, 2.0, np.nan, 9.0, np.nan],
... "Y": [7, 7, 9, 8, 10],
... "Z": pd.Categorical(["j", "k", "l", "k", "j"]),
... })
>>> path = "/My_path/filename.dta"
>>> labels = {"fully_labelled": {1: "one", 2: "two", 3: "three"},
... "partially_labelled": {1.0: "one", 2.0: "two"},
... }
>>> writer = pd.io.stata.StataWriter(path,
... df,
... value_labels=labels) # doctest: +SKIP
>>> writer.write_file() # doctest: +SKIP
>>> df = pd.read_stata(path) # doctest: +SKIP
>>> df # doctest: +SKIP
index fully_labelled partially_labeled Y Z
0 0 one one 7 j
1 1 two two 7 k
2 2 three NaN 9 l
3 3 three 9.0 8 k
4 4 one NaN 10 j
"""
with get_handle(
self._fname,
Expand Down