pandas 1.4.2

ParametersReturns
resample(self, rule, *args, **kwargs)

Given a grouper, the function resamples it according to a string "string" -> "frequency".

See the frequency aliases <timeseries.offset_aliases> documentation for more details.

Parameters

rule : str or DateOffset

The offset string or object representing target grouper conversion.

*args, **kwargs :

Possible arguments are :None:None:`how`, :None:None:`fill_method`, :None:None:`limit`, kind and :None:None:`on`, and other arguments of :None:None:`TimeGrouper`.

Returns

Grouper

Return a new grouper with our resampler appended.

Provide resampling when using a TimeGrouper.

See Also

DatetimeIndex.resample

Frequency conversion and resampling of time series.

Grouper

Specify a frequency to resample with when grouping by a key.

Examples

This example is valid syntax, but we were not able to check execution
>>> idx = pd.date_range('1/1/2000', periods=4, freq='T')
... df = pd.DataFrame(data=4 * [range(2)],
...  index=idx,
...  columns=['a', 'b'])
... df.iloc[2, 0] = 5
... df a b 2000-01-01 00:00:00 0 1 2000-01-01 00:01:00 0 1 2000-01-01 00:02:00 5 1 2000-01-01 00:03:00 0 1

Downsample the DataFrame into 3 minute bins and sum the values of the timestamps falling into a bin.

This example is valid syntax, but we were not able to check execution
>>> df.groupby('a').resample('3T').sum()
                         a  b
a
0   2000-01-01 00:00:00  0  2
    2000-01-01 00:03:00  0  1
5   2000-01-01 00:00:00  5  1

Upsample the series into 30 second bins.

This example is valid syntax, but we were not able to check execution
>>> df.groupby('a').resample('30S').sum()
                    a  b
a
0   2000-01-01 00:00:00  0  1
    2000-01-01 00:00:30  0  0
    2000-01-01 00:01:00  0  1
    2000-01-01 00:01:30  0  0
    2000-01-01 00:02:00  0  0
    2000-01-01 00:02:30  0  0
    2000-01-01 00:03:00  0  1
5   2000-01-01 00:02:00  5  1

Resample by month. Values are assigned to the month of the period.

This example is valid syntax, but we were not able to check execution
>>> df.groupby('a').resample('M').sum()
            a  b
a
0   2000-01-31  0  3
5   2000-01-31  5  1

Downsample the series into 3 minute bins as above, but close the right side of the bin interval.

This example is valid syntax, but we were not able to check execution
>>> df.groupby('a').resample('3T', closed='right').sum()
                         a  b
a
0   1999-12-31 23:57:00  0  1
    2000-01-01 00:00:00  0  2
5   2000-01-01 00:00:00  5  1

Downsample the series into 3 minute bins and close the right side of the bin interval, but label each bin using the right edge instead of the left.

This example is valid syntax, but we were not able to check execution
>>> df.groupby('a').resample('3T', closed='right', label='right').sum()
                         a  b
a
0   2000-01-01 00:00:00  0  1
    2000-01-01 00:03:00  0  2
5   2000-01-01 00:03:00  5  1
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /pandas/core/groupby/groupby.py#2317
type: <class 'function'>
Commit: