Skip to content

Commit e4468c9

Browse files
authored
DOC: fix docstring for DataFrame.to_period, pandas.DataFrame.to_timestamp, pandas.DataFrame.tz_convert #58065 (#58101)
* Add See Also section to to_period method. * Add See Also section to to_timestamp method. * Add See Also section to tz_convert method. * fix typo in to_timestamp * Fix formatting of See Also * Remove fixed methods from code check ignore list. * Fix formatting * Revert accidentally included docstring changes. * fix merge issues * Fix pre commit hooks * Fix line break issues.
1 parent a9359ba commit e4468c9

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
lines changed

ci/code_checks.sh

-6
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
120120
-i "pandas.DataFrame.to_feather SA01" \
121121
-i "pandas.DataFrame.to_markdown SA01" \
122122
-i "pandas.DataFrame.to_parquet RT03" \
123-
-i "pandas.DataFrame.to_period SA01" \
124-
-i "pandas.DataFrame.to_timestamp SA01" \
125-
-i "pandas.DataFrame.tz_convert SA01" \
126123
-i "pandas.DataFrame.var PR01,RT03,SA01" \
127124
-i "pandas.DatetimeIndex.ceil SA01" \
128125
-i "pandas.DatetimeIndex.date SA01" \
@@ -467,11 +464,8 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
467464
-i "pandas.Series.to_frame SA01" \
468465
-i "pandas.Series.to_list RT03" \
469466
-i "pandas.Series.to_markdown SA01" \
470-
-i "pandas.Series.to_period SA01" \
471467
-i "pandas.Series.to_string SA01" \
472-
-i "pandas.Series.to_timestamp RT03,SA01" \
473468
-i "pandas.Series.truediv PR07" \
474-
-i "pandas.Series.tz_convert SA01" \
475469
-i "pandas.Series.update PR07,SA01" \
476470
-i "pandas.Series.var PR01,RT03,SA01" \
477471
-i "pandas.SparseDtype SA01" \

pandas/core/frame.py

+18-5
Original file line numberDiff line numberDiff line change
@@ -12482,7 +12482,9 @@ def to_timestamp(
1248212482
copy: bool | lib.NoDefault = lib.no_default,
1248312483
) -> DataFrame:
1248412484
"""
12485-
Cast to DatetimeIndex of timestamps, at *beginning* of period.
12485+
Cast PeriodIndex to DatetimeIndex of timestamps, at *beginning* of period.
12486+
12487+
This can be changed to the *end* of the period, by specifying `how="e"`.
1248612488
1248712489
Parameters
1248812490
----------
@@ -12512,8 +12514,13 @@ def to_timestamp(
1251212514
1251312515
Returns
1251412516
-------
12515-
DataFrame
12516-
The DataFrame has a DatetimeIndex.
12517+
DataFrame with DatetimeIndex
12518+
DataFrame with the PeriodIndex cast to DatetimeIndex.
12519+
12520+
See Also
12521+
--------
12522+
DataFrame.to_period: Inverse method to cast DatetimeIndex to PeriodIndex.
12523+
Series.to_timestamp: Equivalent method for Series.
1251712524
1251812525
Examples
1251912526
--------
@@ -12569,7 +12576,8 @@ def to_period(
1256912576
Convert DataFrame from DatetimeIndex to PeriodIndex.
1257012577
1257112578
Convert DataFrame from DatetimeIndex to PeriodIndex with desired
12572-
frequency (inferred from index if not passed).
12579+
frequency (inferred from index if not passed). Either index of columns can be
12580+
converted, depending on `axis` argument.
1257312581
1257412582
Parameters
1257512583
----------
@@ -12597,7 +12605,12 @@ def to_period(
1259712605
Returns
1259812606
-------
1259912607
DataFrame
12600-
The DataFrame has a PeriodIndex.
12608+
The DataFrame with the converted PeriodIndex.
12609+
12610+
See Also
12611+
--------
12612+
Series.to_period: Equivalent method for Series.
12613+
Series.dt.to_period: Convert DateTime column values.
1260112614
1260212615
Examples
1260312616
--------

pandas/core/generic.py

+5
Original file line numberDiff line numberDiff line change
@@ -10394,6 +10394,11 @@ def tz_convert(
1039410394
TypeError
1039510395
If the axis is tz-naive.
1039610396
10397+
See Also
10398+
--------
10399+
DataFrame.tz_localize: Localize tz-naive index of DataFrame to target time zone.
10400+
Series.tz_localize: Localize tz-naive index of Series to target time zone.
10401+
1039710402
Examples
1039810403
--------
1039910404
Change to another time zone:

pandas/core/series.py

+13
Original file line numberDiff line numberDiff line change
@@ -5613,6 +5613,8 @@ def to_timestamp(
56135613
"""
56145614
Cast to DatetimeIndex of Timestamps, at *beginning* of period.
56155615
5616+
This can be changed to the *end* of the period, by specifying `how="e"`.
5617+
56165618
Parameters
56175619
----------
56185620
freq : str, default frequency of PeriodIndex
@@ -5640,6 +5642,12 @@ def to_timestamp(
56405642
Returns
56415643
-------
56425644
Series with DatetimeIndex
5645+
Series with the PeriodIndex cast to DatetimeIndex.
5646+
5647+
See Also
5648+
--------
5649+
Series.to_period: Inverse method to cast DatetimeIndex to PeriodIndex.
5650+
DataFrame.to_timestamp: Equivalent method for DataFrame.
56435651
56445652
Examples
56455653
--------
@@ -5713,6 +5721,11 @@ def to_period(
57135721
Series
57145722
Series with index converted to PeriodIndex.
57155723
5724+
See Also
5725+
--------
5726+
DataFrame.to_period: Equivalent method for DataFrame.
5727+
Series.dt.to_period: Convert DateTime column values.
5728+
57165729
Examples
57175730
--------
57185731
>>> idx = pd.DatetimeIndex(["2023", "2024", "2025"])

0 commit comments

Comments
 (0)