Skip to content

Commit 95d10ae

Browse files
committed
Merge remote-tracking branch 'upstream/main' into ref/index_equiv
2 parents 205f776 + 33af3b8 commit 95d10ae

File tree

7 files changed

+47
-31
lines changed

7 files changed

+47
-31
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ci:
1919
skip: [pylint, pyright, mypy]
2020
repos:
2121
- repo: https://github.com/astral-sh/ruff-pre-commit
22-
rev: v0.3.1
22+
rev: v0.3.4
2323
hooks:
2424
- id: ruff
2525
args: [--exit-non-zero-on-fix]
@@ -39,7 +39,7 @@ repos:
3939
- id: ruff-format
4040
exclude: ^scripts
4141
- repo: https://github.com/jendrikseipp/vulture
42-
rev: 'v2.10'
42+
rev: 'v2.11'
4343
hooks:
4444
- id: vulture
4545
entry: python scripts/run_vulture.py
@@ -93,11 +93,11 @@ repos:
9393
args: [--disable=all, --enable=redefined-outer-name]
9494
stages: [manual]
9595
- repo: https://github.com/PyCQA/isort
96-
rev: 5.12.0
96+
rev: 5.13.2
9797
hooks:
9898
- id: isort
9999
- repo: https://github.com/asottile/pyupgrade
100-
rev: v3.15.0
100+
rev: v3.15.2
101101
hooks:
102102
- id: pyupgrade
103103
args: [--py39-plus]
@@ -116,7 +116,7 @@ repos:
116116
hooks:
117117
- id: sphinx-lint
118118
- repo: https://github.com/pre-commit/mirrors-clang-format
119-
rev: v17.0.6
119+
rev: v18.1.2
120120
hooks:
121121
- id: clang-format
122122
files: ^pandas/_libs/src|^pandas/_libs/include

ci/code_checks.sh

Lines changed: 0 additions & 6 deletions
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

Lines changed: 18 additions & 5 deletions
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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7718,11 +7718,6 @@ def interpolate(
77187718
raise ValueError("'method' should be a string, not None.")
77197719

77207720
obj, should_transpose = (self.T, True) if axis == 1 else (self, False)
7721-
# GH#53631
7722-
if np.any(obj.dtypes == object):
7723-
raise TypeError(
7724-
f"{type(self).__name__} cannot interpolate with object dtype."
7725-
)
77267721

77277722
if isinstance(obj.index, MultiIndex) and method != "linear":
77287723
raise ValueError(
@@ -10394,6 +10389,11 @@ def tz_convert(
1039410389
TypeError
1039510390
If the axis is tz-naive.
1039610391
10392+
See Also
10393+
--------
10394+
DataFrame.tz_localize: Localize tz-naive index of DataFrame to target time zone.
10395+
Series.tz_localize: Localize tz-naive index of Series to target time zone.
10396+
1039710397
Examples
1039810398
--------
1039910399
Change to another time zone:

pandas/core/internals/blocks.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,12 +1388,10 @@ def interpolate(
13881388
# If there are no NAs, then interpolate is a no-op
13891389
return [self.copy(deep=False)]
13901390

1391-
# TODO(3.0): this case will not be reachable once GH#53638 is enforced
13921391
if self.dtype == _dtype_obj:
1393-
# only deal with floats
1394-
# bc we already checked that can_hold_na, we don't have int dtype here
1395-
# test_interp_basic checks that we make a copy here
1396-
return [self.copy(deep=False)]
1392+
# GH#53631
1393+
name = {1: "Series", 2: "DataFrame"}[self.ndim]
1394+
raise TypeError(f"{name} cannot interpolate with object dtype.")
13971395

13981396
copy, refs = self._get_refs_and_copy(inplace)
13991397

pandas/core/series.py

Lines changed: 13 additions & 0 deletions
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"])

pandas/tests/series/methods/test_interpolate.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -790,11 +790,9 @@ def test_interpolate_unsorted_index(self, ascending, expected_values):
790790

791791
def test_interpolate_asfreq_raises(self):
792792
ser = Series(["a", None, "b"], dtype=object)
793-
msg2 = "Series cannot interpolate with object dtype"
794-
msg = "Invalid fill method"
795-
with pytest.raises(TypeError, match=msg2):
796-
with pytest.raises(ValueError, match=msg):
797-
ser.interpolate(method="asfreq")
793+
msg = "Can not interpolate with method=asfreq"
794+
with pytest.raises(ValueError, match=msg):
795+
ser.interpolate(method="asfreq")
798796

799797
def test_interpolate_fill_value(self):
800798
# GH#54920

0 commit comments

Comments
 (0)