Skip to content

Commit 094ca68

Browse files
authored
DOC: Fix docstring errors for pandas.DataFrame.unstack, pandas.DataFrame.value_counts and pandas.DataFrame.tz_localize (#58097)
* Add results information to unstack method docstring. * Add result docstring to value_counts method. * Add See also section to DataFrame.tz_localize method. * Add See also section for unstack method of Series. * Remove methods from code check ignore list * Fix order of docstring sections. * Fix further validation errors. * Reinsert method to ignore list.
1 parent e3f9298 commit 094ca68

File tree

5 files changed

+21
-14
lines changed

5 files changed

+21
-14
lines changed

ci/code_checks.sh

-7
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
127127
-i "pandas.DataFrame.to_period SA01" \
128128
-i "pandas.DataFrame.to_timestamp SA01" \
129129
-i "pandas.DataFrame.tz_convert SA01" \
130-
-i "pandas.DataFrame.tz_localize SA01" \
131-
-i "pandas.DataFrame.unstack RT03" \
132-
-i "pandas.DataFrame.value_counts RT03" \
133130
-i "pandas.DataFrame.var PR01,RT03,SA01" \
134131
-i "pandas.DataFrame.where RT03" \
135132
-i "pandas.DatetimeIndex.ceil SA01" \
@@ -226,7 +223,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
226223
-i "pandas.Index.to_list RT03" \
227224
-i "pandas.Index.union PR07,RT03,SA01" \
228225
-i "pandas.Index.unique RT03" \
229-
-i "pandas.Index.value_counts RT03" \
230226
-i "pandas.Index.view GL08" \
231227
-i "pandas.Int16Dtype SA01" \
232228
-i "pandas.Int32Dtype SA01" \
@@ -482,10 +478,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
482478
-i "pandas.Series.to_timestamp RT03,SA01" \
483479
-i "pandas.Series.truediv PR07" \
484480
-i "pandas.Series.tz_convert SA01" \
485-
-i "pandas.Series.tz_localize SA01" \
486-
-i "pandas.Series.unstack SA01" \
487481
-i "pandas.Series.update PR07,SA01" \
488-
-i "pandas.Series.value_counts RT03" \
489482
-i "pandas.Series.var PR01,RT03,SA01" \
490483
-i "pandas.Series.where RT03" \
491484
-i "pandas.SparseDtype SA01" \

pandas/core/base.py

+1
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,7 @@ def value_counts(
924924
Returns
925925
-------
926926
Series
927+
Series containing counts of unique values.
927928
928929
See Also
929930
--------

pandas/core/frame.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -7162,7 +7162,7 @@ def value_counts(
71627162
dropna: bool = True,
71637163
) -> Series:
71647164
"""
7165-
Return a Series containing the frequency of each distinct row in the Dataframe.
7165+
Return a Series containing the frequency of each distinct row in the DataFrame.
71667166
71677167
Parameters
71687168
----------
@@ -7175,13 +7175,14 @@ def value_counts(
71757175
ascending : bool, default False
71767176
Sort in ascending order.
71777177
dropna : bool, default True
7178-
Don't include counts of rows that contain NA values.
7178+
Do not include counts of rows that contain NA values.
71797179
71807180
.. versionadded:: 1.3.0
71817181
71827182
Returns
71837183
-------
71847184
Series
7185+
Series containing the frequency of each distinct row in the DataFrame.
71857186
71867187
See Also
71877188
--------
@@ -7192,8 +7193,8 @@ def value_counts(
71927193
The returned Series will have a MultiIndex with one level per input
71937194
column but an Index (non-multi) for a single label. By default, rows
71947195
that contain any NA values are omitted from the result. By default,
7195-
the resulting Series will be in descending order so that the first
7196-
element is the most frequently-occurring row.
7196+
the resulting Series will be sorted by frequencies in descending order so that
7197+
the first element is the most frequently-occurring row.
71977198
71987199
Examples
71997200
--------
@@ -9658,6 +9659,8 @@ def unstack(
96589659
Returns
96599660
-------
96609661
Series or DataFrame
9662+
If index is a MultiIndex: DataFrame with pivoted index labels as new
9663+
inner-most level column labels, else Series.
96619664
96629665
See Also
96639666
--------

pandas/core/generic.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -10485,10 +10485,10 @@ def tz_localize(
1048510485
nonexistent: TimeNonexistent = "raise",
1048610486
) -> Self:
1048710487
"""
10488-
Localize tz-naive index of a Series or DataFrame to target time zone.
10488+
Localize time zone naive index of a Series or DataFrame to target time zone.
1048910489
1049010490
This operation localizes the Index. To localize the values in a
10491-
timezone-naive Series, use :meth:`Series.dt.tz_localize`.
10491+
time zone naive Series, use :meth:`Series.dt.tz_localize`.
1049210492
1049310493
Parameters
1049410494
----------
@@ -10548,13 +10548,19 @@ def tz_localize(
1054810548
Returns
1054910549
-------
1055010550
{klass}
10551-
Same type as the input.
10551+
Same type as the input, with time zone naive or aware index, depending on
10552+
``tz``.
1055210553
1055310554
Raises
1055410555
------
1055510556
TypeError
1055610557
If the TimeSeries is tz-aware and tz is not None.
1055710558
10559+
See Also
10560+
--------
10561+
Series.dt.tz_localize: Localize the values in a time zone naive Series.
10562+
Timestamp.tz_localize: Localize the Timestamp to a timezone.
10563+
1055810564
Examples
1055910565
--------
1056010566
Localize local times:

pandas/core/series.py

+4
Original file line numberDiff line numberDiff line change
@@ -4257,6 +4257,10 @@ def unstack(
42574257
DataFrame
42584258
Unstacked Series.
42594259
4260+
See Also
4261+
--------
4262+
DataFrame.unstack : Pivot the MultiIndex of a DataFrame.
4263+
42604264
Notes
42614265
-----
42624266
Reference :ref:`the user guide <reshaping.stacking>` for more examples.

0 commit comments

Comments
 (0)