Skip to content

Commit 5bf9111

Browse files
committed
fix: Fixes wrong doctest output in pandas.core.resample.Resampler.interpolate and the related explanation about consideration of anchor points when interpolating downsampled series with non-aligned result index.
1 parent 9034c6f commit 5bf9111

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

pandas/core/resample.py

+13-12
Original file line numberDiff line numberDiff line change
@@ -1063,25 +1063,26 @@ def interpolate(
10631063
Freq: 500ms, dtype: float64
10641064
10651065
Internal reindexing with ``asfreq()`` prior to interpolation leads to
1066-
an interpolated timeseries on the basis the reindexed timestamps (anchors).
1067-
Since not all datapoints from original series become anchors,
1068-
it can lead to misleading interpolation results as in the following example:
1066+
an interpolated timeseries on the basis of the reindexed timestamps
1067+
(anchors). It is assured that all available datapoints from original
1068+
series become anchors, so it also works for resampling-cases that lead
1069+
to non-aligned timestamps, as in the following example:
10691070
10701071
>>> series.resample("400ms").interpolate("linear")
10711072
2023-03-01 07:00:00.000 1.0
1072-
2023-03-01 07:00:00.400 1.2
1073-
2023-03-01 07:00:00.800 1.4
1074-
2023-03-01 07:00:01.200 1.6
1075-
2023-03-01 07:00:01.600 1.8
1073+
2023-03-01 07:00:00.400 0.2
1074+
2023-03-01 07:00:00.800 -0.6
1075+
2023-03-01 07:00:01.200 -0.4
1076+
2023-03-01 07:00:01.600 0.8
10761077
2023-03-01 07:00:02.000 2.0
1077-
2023-03-01 07:00:02.400 2.2
1078-
2023-03-01 07:00:02.800 2.4
1079-
2023-03-01 07:00:03.200 2.6
1080-
2023-03-01 07:00:03.600 2.8
1078+
2023-03-01 07:00:02.400 1.6
1079+
2023-03-01 07:00:02.800 1.2
1080+
2023-03-01 07:00:03.200 1.4
1081+
2023-03-01 07:00:03.600 2.2
10811082
2023-03-01 07:00:04.000 3.0
10821083
Freq: 400ms, dtype: float64
10831084
1084-
Note that the series erroneously increases between two anchors
1085+
Note that the series correctly decreases between two anchors
10851086
``07:00:00`` and ``07:00:02``.
10861087
"""
10871088
assert downcast is lib.no_default # just checking coverage

0 commit comments

Comments
 (0)