Skip to content

DOC: fix docstring for DataFrame.to_period, pandas.DataFrame.to_timestamp, pandas.DataFrame.tz_convert #58065 #58101

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

6 changes: 0 additions & 6 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.DataFrame.to_feather SA01" \
-i "pandas.DataFrame.to_markdown SA01" \
-i "pandas.DataFrame.to_parquet RT03" \
-i "pandas.DataFrame.to_period SA01" \
-i "pandas.DataFrame.to_timestamp SA01" \
-i "pandas.DataFrame.tz_convert SA01" \
-i "pandas.DataFrame.var PR01,RT03,SA01" \
-i "pandas.DataFrame.where RT03" \
-i "pandas.DatetimeIndex.ceil SA01" \
Expand Down Expand Up @@ -470,11 +467,8 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.Series.to_frame SA01" \
-i "pandas.Series.to_list RT03" \
-i "pandas.Series.to_markdown SA01" \
-i "pandas.Series.to_period SA01" \
-i "pandas.Series.to_string SA01" \
-i "pandas.Series.to_timestamp RT03,SA01" \
-i "pandas.Series.truediv PR07" \
-i "pandas.Series.tz_convert SA01" \
-i "pandas.Series.update PR07,SA01" \
-i "pandas.Series.var PR01,RT03,SA01" \
-i "pandas.Series.where RT03" \
Expand Down
23 changes: 18 additions & 5 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -12482,7 +12482,9 @@ def to_timestamp(
copy: bool | lib.NoDefault = lib.no_default,
) -> DataFrame:
"""
Cast to DatetimeIndex of timestamps, at *beginning* of period.
Cast PeriodIndex to DatetimeIndex of timestamps, at *beginning* of period.

This can be changed to the *end* of the period, by specifying `how="e"`.

Parameters
----------
Expand Down Expand Up @@ -12512,8 +12514,13 @@ def to_timestamp(

Returns
-------
DataFrame
The DataFrame has a DatetimeIndex.
DataFrame with DatetimeIndex
DataFrame with the PeriodIndex cast to DatetimeIndex.

See Also
--------
DataFrame.to_period: Inverse method to cast DatetimeIndex to PeriodIndex.
Series.to_timestamp: Equivalent method for Series.

Examples
--------
Expand Down Expand Up @@ -12569,7 +12576,8 @@ def to_period(
Convert DataFrame from DatetimeIndex to PeriodIndex.

Convert DataFrame from DatetimeIndex to PeriodIndex with desired
frequency (inferred from index if not passed).
frequency (inferred from index if not passed). Either index of columns can be
converted, depending on `axis` argument.

Parameters
----------
Expand Down Expand Up @@ -12597,7 +12605,12 @@ def to_period(
Returns
-------
DataFrame
The DataFrame has a PeriodIndex.
The DataFrame with the converted PeriodIndex.

See Also
--------
Series.to_period: Equivalent method for Series.
Series.dt.to_period: Convert DateTime column values.

Examples
--------
Expand Down
5 changes: 5 additions & 0 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -10423,6 +10423,11 @@ def tz_convert(
TypeError
If the axis is tz-naive.

See Also
--------
DataFrame.tz_localize: Localize tz-naive index of DataFrame to target time zone.
Series.tz_localize: Localize tz-naive index of Series to target time zone.

Examples
--------
Change to another time zone:
Expand Down
13 changes: 13 additions & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -5648,6 +5648,8 @@ def to_timestamp(
"""
Cast to DatetimeIndex of Timestamps, at *beginning* of period.

This can be changed to the *end* of the period, by specifying `how="e"`.

Parameters
----------
freq : str, default frequency of PeriodIndex
Expand Down Expand Up @@ -5675,6 +5677,12 @@ def to_timestamp(
Returns
-------
Series with DatetimeIndex
Series with the PeriodIndex cast to DatetimeIndex.

See Also
--------
Series.to_period: Inverse method to cast DatetimeIndex to PeriodIndex.
DataFrame.to_timestamp: Equivalent method for DataFrame.

Examples
--------
Expand Down Expand Up @@ -5748,6 +5756,11 @@ def to_period(
Series
Series with index converted to PeriodIndex.

See Also
--------
DataFrame.to_period: Equivalent method for DataFrame.
Series.dt.to_period: Convert DateTime column values.

Examples
--------
>>> idx = pd.DatetimeIndex(["2023", "2024", "2025"])
Expand Down