@@ -7713,7 +7713,7 @@ def clip(
7713
7713
7714
7714
return result
7715
7715
7716
- @final
7716
+ @doc ( ** _shared_doc_kwargs )
7717
7717
def asfreq (
7718
7718
self : FrameOrSeries ,
7719
7719
freq ,
@@ -7723,26 +7723,39 @@ def asfreq(
7723
7723
fill_value = None ,
7724
7724
) -> FrameOrSeries :
7725
7725
"""
7726
- Convert TimeSeries to specified frequency.
7727
-
7728
- Optionally provide filling method to pad/backfill missing values.
7726
+ Convert time series to specified frequency.
7729
7727
7730
7728
Returns the original data conformed to a new index with the specified
7731
- frequency. ``resample`` is more appropriate if an operation, such as
7732
- summarization, is necessary to represent the data at the new frequency.
7729
+ frequency.
7730
+
7731
+ If the index of this {klass} is a :class:`~pandas.PeriodIndex`, the new index
7732
+ is the result of transforming the original index with
7733
+ :meth:`PeriodIndex.asfreq <pandas.PeriodIndex.asfreq>` (so the original index
7734
+ will map one-to-one to the new index).
7735
+
7736
+ Otherwise, the new index will be equivalent to ``pd.date_range(start, end,
7737
+ freq=freq)`` where ``start`` and ``end`` are, respectively, the first and
7738
+ last entries in the original index (see :func:`pandas.date_range`). The
7739
+ values corresponding to any timesteps in the new index which were not present
7740
+ in the original index will be null (``NaN``), unless a method for filling
7741
+ such unknowns is provided (see the ``method`` parameter below).
7742
+
7743
+ The :meth:`resample` method is more appropriate if an operation on each group of
7744
+ timesteps (such as an aggregate) is necessary to represent the data at the new
7745
+ frequency.
7733
7746
7734
7747
Parameters
7735
7748
----------
7736
7749
freq : DateOffset or str
7737
7750
Frequency DateOffset or string.
7738
- method : {'backfill'/'bfill', 'pad'/'ffill'}, default None
7751
+ method : {{ 'backfill'/'bfill', 'pad'/'ffill'} }, default None
7739
7752
Method to use for filling holes in reindexed Series (note this
7740
7753
does not fill NaNs that already were present):
7741
7754
7742
7755
* 'pad' / 'ffill': propagate last valid observation forward to next
7743
7756
valid
7744
7757
* 'backfill' / 'bfill': use NEXT valid observation to fill.
7745
- how : {'start', 'end'}, default end
7758
+ how : {{ 'start', 'end'} }, default end
7746
7759
For PeriodIndex only (see PeriodIndex.asfreq).
7747
7760
normalize : bool, default False
7748
7761
Whether to reset output index to midnight.
@@ -7752,8 +7765,8 @@ def asfreq(
7752
7765
7753
7766
Returns
7754
7767
-------
7755
- Same type as caller
7756
- Object converted to the specified frequency.
7768
+ {klass}
7769
+ {klass} object reindexed to the specified frequency.
7757
7770
7758
7771
See Also
7759
7772
--------
@@ -7770,7 +7783,7 @@ def asfreq(
7770
7783
7771
7784
>>> index = pd.date_range('1/1/2000', periods=4, freq='T')
7772
7785
>>> series = pd.Series([0.0, None, 2.0, 3.0], index=index)
7773
- >>> df = pd.DataFrame({'s':series})
7786
+ >>> df = pd.DataFrame({{ 's': series} })
7774
7787
>>> df
7775
7788
s
7776
7789
2000-01-01 00:00:00 0.0
@@ -7969,7 +7982,7 @@ def between_time(
7969
7982
)
7970
7983
return self ._take_with_is_copy (indexer , axis = axis )
7971
7984
7972
- @final
7985
+ @doc ( ** _shared_doc_kwargs )
7973
7986
def resample (
7974
7987
self ,
7975
7988
rule ,
@@ -7988,31 +8001,31 @@ def resample(
7988
8001
"""
7989
8002
Resample time-series data.
7990
8003
7991
- Convenience method for frequency conversion and resampling of time
7992
- series. Object must have a datetime-like index (`DatetimeIndex`,
7993
- `PeriodIndex`, or `TimedeltaIndex`), or pass datetime-like values
7994
- to the `on` or ` level` keyword.
8004
+ Convenience method for frequency conversion and resampling of time series.
8005
+ The object must have a datetime-like index (`DatetimeIndex`, `PeriodIndex `,
8006
+ or `TimedeltaIndex`), or the caller must pass the label of a datetime-like
8007
+ series/index to the `` on``/`` level`` keyword parameter .
7995
8008
7996
8009
Parameters
7997
8010
----------
7998
8011
rule : DateOffset, Timedelta or str
7999
8012
The offset string or object representing target conversion.
8000
- axis : {0 or 'index', 1 or 'columns'}, default 0
8013
+ axis : {{ 0 or 'index', 1 or 'columns'} }, default 0
8001
8014
Which axis to use for up- or down-sampling. For `Series` this
8002
8015
will default to 0, i.e. along the rows. Must be
8003
8016
`DatetimeIndex`, `TimedeltaIndex` or `PeriodIndex`.
8004
- closed : {'right', 'left'}, default None
8017
+ closed : {{ 'right', 'left'} }, default None
8005
8018
Which side of bin interval is closed. The default is 'left'
8006
8019
for all frequency offsets except for 'M', 'A', 'Q', 'BM',
8007
8020
'BA', 'BQ', and 'W' which all have a default of 'right'.
8008
- label : {'right', 'left'}, default None
8021
+ label : {{ 'right', 'left'} }, default None
8009
8022
Which bin edge label to label bucket with. The default is 'left'
8010
8023
for all frequency offsets except for 'M', 'A', 'Q', 'BM',
8011
8024
'BA', 'BQ', and 'W' which all have a default of 'right'.
8012
- convention : {'start', 'end', 's', 'e'}, default 'start'
8025
+ convention : {{ 'start', 'end', 's', 'e'} }, default 'start'
8013
8026
For `PeriodIndex` only, controls whether to use the start or
8014
8027
end of `rule`.
8015
- kind : {'timestamp', 'period'}, optional, default None
8028
+ kind : {{ 'timestamp', 'period'} }, optional, default None
8016
8029
Pass 'timestamp' to convert the resulting index to a
8017
8030
`DateTimeIndex` or 'period' to convert it to a `PeriodIndex`.
8018
8031
By default the input representation is retained.
@@ -8037,7 +8050,7 @@ def resample(
8037
8050
level : str or int, optional
8038
8051
For a MultiIndex, level (name or number) to use for
8039
8052
resampling. `level` must be datetime-like.
8040
- origin : {'epoch', 'start', 'start_day'}, Timestamp or str, default 'start_day'
8053
+ origin : {{ 'epoch','start','start_day'} }, Timestamp or str, default 'start_day'
8041
8054
The timestamp on which to adjust the grouping. The timezone of origin
8042
8055
must match the timezone of the index.
8043
8056
If a timestamp is not used, these values are also supported:
@@ -8055,13 +8068,15 @@ def resample(
8055
8068
8056
8069
Returns
8057
8070
-------
8058
- Resampler object
8071
+ pandas.core.Resampler
8072
+ :class:`~pandas.core.Resampler` object.
8059
8073
8060
8074
See Also
8061
8075
--------
8062
- groupby : Group by mapping, function, label, or list of labels.
8063
8076
Series.resample : Resample a Series.
8064
- DataFrame.resample: Resample a DataFrame.
8077
+ DataFrame.resample : Resample a DataFrame.
8078
+ groupby : Group {klass} by mapping, function, label, or list of labels.
8079
+ asfreq : Reindex a {klass} with the given frequency without grouping.
8065
8080
8066
8081
Notes
8067
8082
-----
@@ -8220,8 +8235,8 @@ def resample(
8220
8235
For DataFrame objects, the keyword `on` can be used to specify the
8221
8236
column instead of the index for resampling.
8222
8237
8223
- >>> d = {'price': [10, 11, 9, 13, 14, 18, 17, 19],
8224
- ... 'volume': [50, 60, 40, 100, 50, 100, 40, 50]}
8238
+ >>> d = {{ 'price': [10, 11, 9, 13, 14, 18, 17, 19],
8239
+ ... 'volume': [50, 60, 40, 100, 50, 100, 40, 50]}}
8225
8240
>>> df = pd.DataFrame(d)
8226
8241
>>> df['week_starting'] = pd.date_range('01/01/2018',
8227
8242
... periods=8,
@@ -8246,13 +8261,14 @@ def resample(
8246
8261
specify on which level the resampling needs to take place.
8247
8262
8248
8263
>>> days = pd.date_range('1/1/2000', periods=4, freq='D')
8249
- >>> d2 = {'price': [10, 11, 9, 13, 14, 18, 17, 19],
8250
- ... 'volume': [50, 60, 40, 100, 50, 100, 40, 50]}
8251
- >>> df2 = pd.DataFrame(d2,
8252
- ... index=pd.MultiIndex.from_product([days,
8253
- ... ['morning',
8254
- ... 'afternoon']]
8255
- ... ))
8264
+ >>> d2 = {{'price': [10, 11, 9, 13, 14, 18, 17, 19],
8265
+ ... 'volume': [50, 60, 40, 100, 50, 100, 40, 50]}}
8266
+ >>> df2 = pd.DataFrame(
8267
+ ... d2,
8268
+ ... index=pd.MultiIndex.from_product(
8269
+ ... [days, ['morning', 'afternoon']]
8270
+ ... )
8271
+ ... )
8256
8272
>>> df2
8257
8273
price volume
8258
8274
2000-01-01 morning 10 50
0 commit comments