@@ -7518,6 +7518,7 @@ def clip(
7518
7518
7519
7519
return result
7520
7520
7521
+ @doc (** _shared_doc_kwargs )
7521
7522
def asfreq (
7522
7523
self : FrameOrSeries ,
7523
7524
freq ,
@@ -7527,26 +7528,39 @@ def asfreq(
7527
7528
fill_value = None ,
7528
7529
) -> FrameOrSeries :
7529
7530
"""
7530
- Convert TimeSeries to specified frequency.
7531
-
7532
- Optionally provide filling method to pad/backfill missing values.
7531
+ Convert time series to specified frequency.
7533
7532
7534
7533
Returns the original data conformed to a new index with the specified
7535
- frequency. ``resample`` is more appropriate if an operation, such as
7536
- summarization, is necessary to represent the data at the new frequency.
7534
+ frequency.
7535
+
7536
+ If the index of this {klass} is a :class:`~pandas.PeriodIndex`, the new index
7537
+ is the result of transforming the original index with
7538
+ :meth:`PeriodIndex.asfreq pandas.PeriodIndex.asfreq` (so the original index
7539
+ will map one-to-one to the new index).
7540
+
7541
+ Otherwise, the new index will be equivalent to ``pd.date_range(start, end,
7542
+ freq=freq)`` where ``start`` and ``end`` are, respectively, the first and
7543
+ last entries in the original index. (see :func:`pandas.date_range`). The
7544
+ values corresponding to any timesteps in the new index which were not present
7545
+ in the original index will be null (``NaN``), unless a method for filling
7546
+ such unknowns is provided (see the ``method`` parameter below).
7547
+
7548
+ The :meth:`resample` method is more appropriate if an operation on each group of
7549
+ timesteps (such as an aggregate) is necessary to represent the data at the new
7550
+ frequency.
7537
7551
7538
7552
Parameters
7539
7553
----------
7540
7554
freq : DateOffset or str
7541
7555
Frequency DateOffset or string.
7542
- method : {'backfill'/'bfill', 'pad'/'ffill'}, default None
7556
+ method : {{ 'backfill'/'bfill', 'pad'/'ffill'} }, default None
7543
7557
Method to use for filling holes in reindexed Series (note this
7544
7558
does not fill NaNs that already were present):
7545
7559
7546
7560
* 'pad' / 'ffill': propagate last valid observation forward to next
7547
7561
valid
7548
7562
* 'backfill' / 'bfill': use NEXT valid observation to fill.
7549
- how : {'start', 'end'}, default end
7563
+ how : {{ 'start', 'end'} }, default end
7550
7564
For PeriodIndex only (see PeriodIndex.asfreq).
7551
7565
normalize : bool, default False
7552
7566
Whether to reset output index to midnight.
@@ -7556,8 +7570,8 @@ def asfreq(
7556
7570
7557
7571
Returns
7558
7572
-------
7559
- Same type as caller
7560
- Object converted to the specified frequency.
7573
+ {klass}
7574
+ {klass} object reindexed to the specified frequency.
7561
7575
7562
7576
See Also
7563
7577
--------
@@ -7574,7 +7588,7 @@ def asfreq(
7574
7588
7575
7589
>>> index = pd.date_range('1/1/2000', periods=4, freq='T')
7576
7590
>>> series = pd.Series([0.0, None, 2.0, 3.0], index=index)
7577
- >>> df = pd.DataFrame({'s':series})
7591
+ >>> df = pd.DataFrame({{ 's':series} })
7578
7592
>>> df
7579
7593
s
7580
7594
2000-01-01 00:00:00 0.0
@@ -7771,6 +7785,7 @@ def between_time(
7771
7785
)
7772
7786
return self ._take_with_is_copy (indexer , axis = axis )
7773
7787
7788
+ @doc (** _shared_doc_kwargs )
7774
7789
def resample (
7775
7790
self ,
7776
7791
rule ,
@@ -7789,31 +7804,31 @@ def resample(
7789
7804
"""
7790
7805
Resample time-series data.
7791
7806
7792
- Convenience method for frequency conversion and resampling of time
7793
- series. Object must have a datetime-like index (`DatetimeIndex`,
7794
- `PeriodIndex`, or `TimedeltaIndex`), or pass datetime-like values
7795
- to the `on` or ` level` keyword.
7807
+ Convenience method for frequency conversion and resampling of time series.
7808
+ The object must have a datetime-like index (`DatetimeIndex`, `PeriodIndex `,
7809
+ or `TimedeltaIndex`), or the caller must pass the label of a datetime-like
7810
+ series/index to the `` on``/`` level`` keyword parameter .
7796
7811
7797
7812
Parameters
7798
7813
----------
7799
7814
rule : DateOffset, Timedelta or str
7800
7815
The offset string or object representing target conversion.
7801
- axis : {0 or 'index', 1 or 'columns'}, default 0
7816
+ axis : {{ 0 or 'index', 1 or 'columns'} }, default 0
7802
7817
Which axis to use for up- or down-sampling. For `Series` this
7803
7818
will default to 0, i.e. along the rows. Must be
7804
7819
`DatetimeIndex`, `TimedeltaIndex` or `PeriodIndex`.
7805
- closed : {'right', 'left'}, default None
7820
+ closed : {{ 'right', 'left'} }, default None
7806
7821
Which side of bin interval is closed. The default is 'left'
7807
7822
for all frequency offsets except for 'M', 'A', 'Q', 'BM',
7808
7823
'BA', 'BQ', and 'W' which all have a default of 'right'.
7809
- label : {'right', 'left'}, default None
7824
+ label : {{ 'right', 'left'} }, default None
7810
7825
Which bin edge label to label bucket with. The default is 'left'
7811
7826
for all frequency offsets except for 'M', 'A', 'Q', 'BM',
7812
7827
'BA', 'BQ', and 'W' which all have a default of 'right'.
7813
- convention : {'start', 'end', 's', 'e'}, default 'start'
7828
+ convention : {{ 'start', 'end', 's', 'e'} }, default 'start'
7814
7829
For `PeriodIndex` only, controls whether to use the start or
7815
7830
end of `rule`.
7816
- kind : {'timestamp', 'period'}, optional, default None
7831
+ kind : {{ 'timestamp', 'period'} }, optional, default None
7817
7832
Pass 'timestamp' to convert the resulting index to a
7818
7833
`DateTimeIndex` or 'period' to convert it to a `PeriodIndex`.
7819
7834
By default the input representation is retained.
@@ -7838,7 +7853,7 @@ def resample(
7838
7853
level : str or int, optional
7839
7854
For a MultiIndex, level (name or number) to use for
7840
7855
resampling. `level` must be datetime-like.
7841
- origin : {'epoch', 'start', 'start_day'}, Timestamp or str, default 'start_day'
7856
+ origin : {{ 'epoch','start','start_day'} }, Timestamp or str, default 'start_day'
7842
7857
The timestamp on which to adjust the grouping. The timezone of origin
7843
7858
must match the timezone of the index.
7844
7859
If a timestamp is not used, these values are also supported:
@@ -7856,13 +7871,15 @@ def resample(
7856
7871
7857
7872
Returns
7858
7873
-------
7859
- Resampler object
7874
+ pandas.core.Resampler
7875
+ :class:`~pandas.core.Resampler` object.
7860
7876
7861
7877
See Also
7862
7878
--------
7863
- groupby : Group by mapping, function, label, or list of labels.
7864
7879
Series.resample : Resample a Series.
7865
- DataFrame.resample: Resample a DataFrame.
7880
+ DataFrame.resample : Resample a DataFrame.
7881
+ groupby : Group {klass} by mapping, function, label, or list of labels.
7882
+ asfreq : Reindex a {klass} with the given frequency without grouping.
7866
7883
7867
7884
Notes
7868
7885
-----
@@ -8021,8 +8038,8 @@ def resample(
8021
8038
For DataFrame objects, the keyword `on` can be used to specify the
8022
8039
column instead of the index for resampling.
8023
8040
8024
- >>> d = dict( {'price': [10, 11, 9, 13, 14, 18, 17, 19],
8025
- ... 'volume': [50, 60, 40, 100, 50, 100, 40, 50]})
8041
+ >>> d = { {'price': [10, 11, 9, 13, 14, 18, 17, 19],
8042
+ ... 'volume': [50, 60, 40, 100, 50, 100, 40, 50]}}
8026
8043
>>> df = pd.DataFrame(d)
8027
8044
>>> df['week_starting'] = pd.date_range('01/01/2018',
8028
8045
... periods=8,
@@ -8047,13 +8064,14 @@ def resample(
8047
8064
specify on which level the resampling needs to take place.
8048
8065
8049
8066
>>> days = pd.date_range('1/1/2000', periods=4, freq='D')
8050
- >>> d2 = dict({'price': [10, 11, 9, 13, 14, 18, 17, 19],
8051
- ... 'volume': [50, 60, 40, 100, 50, 100, 40, 50]})
8052
- >>> df2 = pd.DataFrame(d2,
8053
- ... index=pd.MultiIndex.from_product([days,
8054
- ... ['morning',
8055
- ... 'afternoon']]
8056
- ... ))
8067
+ >>> d2 = {{'price': [10, 11, 9, 13, 14, 18, 17, 19],
8068
+ ... 'volume': [50, 60, 40, 100, 50, 100, 40, 50]}}
8069
+ >>> df2 = pd.DataFrame(
8070
+ ... d2,
8071
+ ... index=pd.MultiIndex.from_product(
8072
+ ... [days, ['morning', 'afternoon']]
8073
+ ... )
8074
+ ... )
8057
8075
>>> df2
8058
8076
price volume
8059
8077
2000-01-01 morning 10 50
0 commit comments