diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 0c4e6641444f1..a9f69ee4f6c57 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -127,9 +127,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.DataFrame.to_period SA01" \ -i "pandas.DataFrame.to_timestamp SA01" \ -i "pandas.DataFrame.tz_convert SA01" \ - -i "pandas.DataFrame.tz_localize SA01" \ - -i "pandas.DataFrame.unstack RT03" \ - -i "pandas.DataFrame.value_counts RT03" \ -i "pandas.DataFrame.var PR01,RT03,SA01" \ -i "pandas.DataFrame.where RT03" \ -i "pandas.DatetimeIndex.ceil SA01" \ @@ -226,7 +223,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Index.to_list RT03" \ -i "pandas.Index.union PR07,RT03,SA01" \ -i "pandas.Index.unique RT03" \ - -i "pandas.Index.value_counts RT03" \ -i "pandas.Index.view GL08" \ -i "pandas.Int16Dtype SA01" \ -i "pandas.Int32Dtype SA01" \ @@ -482,10 +478,7 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.Series.to_timestamp RT03,SA01" \ -i "pandas.Series.truediv PR07" \ -i "pandas.Series.tz_convert SA01" \ - -i "pandas.Series.tz_localize SA01" \ - -i "pandas.Series.unstack SA01" \ -i "pandas.Series.update PR07,SA01" \ - -i "pandas.Series.value_counts RT03" \ -i "pandas.Series.var PR01,RT03,SA01" \ -i "pandas.Series.where RT03" \ -i "pandas.SparseDtype SA01" \ diff --git a/pandas/core/base.py b/pandas/core/base.py index 263265701691b..f923106e967b7 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -924,6 +924,7 @@ def value_counts( Returns ------- Series + Series containing counts of unique values. See Also -------- diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 50a93994dc76b..abb8d13342c9d 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -7162,7 +7162,7 @@ def value_counts( dropna: bool = True, ) -> Series: """ - Return a Series containing the frequency of each distinct row in the Dataframe. + Return a Series containing the frequency of each distinct row in the DataFrame. Parameters ---------- @@ -7175,13 +7175,14 @@ def value_counts( ascending : bool, default False Sort in ascending order. dropna : bool, default True - Don't include counts of rows that contain NA values. + Do not include counts of rows that contain NA values. .. versionadded:: 1.3.0 Returns ------- Series + Series containing the frequency of each distinct row in the DataFrame. See Also -------- @@ -7192,8 +7193,8 @@ def value_counts( The returned Series will have a MultiIndex with one level per input column but an Index (non-multi) for a single label. By default, rows that contain any NA values are omitted from the result. By default, - the resulting Series will be in descending order so that the first - element is the most frequently-occurring row. + the resulting Series will be sorted by frequencies in descending order so that + the first element is the most frequently-occurring row. Examples -------- @@ -9658,6 +9659,8 @@ def unstack( Returns ------- Series or DataFrame + If index is a MultiIndex: DataFrame with pivoted index labels as new + inner-most level column labels, else Series. See Also -------- diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 858d2ba82a969..ee1ce2f817b6c 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -10485,10 +10485,10 @@ def tz_localize( nonexistent: TimeNonexistent = "raise", ) -> Self: """ - Localize tz-naive index of a Series or DataFrame to target time zone. + Localize time zone naive index of a Series or DataFrame to target time zone. This operation localizes the Index. To localize the values in a - timezone-naive Series, use :meth:`Series.dt.tz_localize`. + time zone naive Series, use :meth:`Series.dt.tz_localize`. Parameters ---------- @@ -10548,13 +10548,19 @@ def tz_localize( Returns ------- {klass} - Same type as the input. + Same type as the input, with time zone naive or aware index, depending on + ``tz``. Raises ------ TypeError If the TimeSeries is tz-aware and tz is not None. + See Also + -------- + Series.dt.tz_localize: Localize the values in a time zone naive Series. + Timestamp.tz_localize: Localize the Timestamp to a timezone. + Examples -------- Localize local times: diff --git a/pandas/core/series.py b/pandas/core/series.py index b0dc05fce7913..843788273a6ef 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -4257,6 +4257,10 @@ def unstack( DataFrame Unstacked Series. + See Also + -------- + DataFrame.unstack : Pivot the MultiIndex of a DataFrame. + Notes ----- Reference :ref:`the user guide ` for more examples.