Skip to content

Commit b8f8b0e

Browse files
committed
DOC: Address PR changes request: string->str, missing defaults, pep8 issues... (pandas-dev#22894)
1 parent 49fbd6b commit b8f8b0e

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

pandas/core/generic.py

+17-16
Original file line numberDiff line numberDiff line change
@@ -7375,39 +7375,40 @@ def resample(self, rule, how=None, axis=0, fill_method=None, closed=None,
73757375
73767376
Parameters
73777377
----------
7378-
rule : string
7378+
rule : str
73797379
The offset string or object representing target conversion.
7380-
how : string
7380+
how : str
73817381
Method for down-/re-sampling, default to ‘mean’ for downsampling.
73827382
73837383
.. deprecated:: 0.18.0
73847384
The new syntax is ``.resample(...).mean()``, or
73857385
``.resample(...).apply(<func>)``
73867386
axis : int, optional, default 0
7387-
Which index to use for up- or down-sampling. Must be
7387+
Which axis to use for up- or down-sampling. For ``Series`` this
7388+
will default to 0, i.e. `along the rows`. Must be
73887389
``DatetimeIndex``, ``TimedeltaIndex`` or ``PeriodIndex``.
7389-
fill_method : string, default None
7390+
fill_method : str, default None
73907391
Filling method for upsampling.
73917392
73927393
.. deprecated:: 0.18.0
73937394
The new syntax is ``.resample(...).<func>()``,
73947395
e.g. ``.resample(...).pad()``
7395-
closed : {'right', 'left'}
7396+
closed : {'right', 'left'}, default None
73967397
Which side of bin interval is closed. The default is 'left'
73977398
for all frequency offsets except for 'M', 'A', 'Q', 'BM',
73987399
'BA', 'BQ', and 'W' which all have a default of 'right'.
7399-
label : {'right', 'left'}
7400+
label : {'right', 'left'}, default None
74007401
Which bin edge label to label bucket with. The default is 'left'
74017402
for all frequency offsets except for 'M', 'A', 'Q', 'BM',
74027403
'BA', 'BQ', and 'W' which all have a default of 'right'.
7403-
convention : {'start', 'end', 's', 'e'}
7404+
convention : {'start', 'end', 's', 'e'}, default 'start'
74047405
For ``PeriodIndex`` only, controls whether to use the start or
74057406
end of ``rule``.
7406-
kind : {'timestamp', 'period'} optional
7407+
kind : {'timestamp', 'period'}, optional, default None
74077408
Pass 'timestamp' to convert the resulting index to a
74087409
``DateTimeIndex`` or 'period' to convert it to a ``PeriodIndex``.
74097410
By default the input representation is retained.
7410-
loffset : timedelta
7411+
loffset : timedelta, default None
74117412
Adjust the resampled time labels.
74127413
limit : int, default None
74137414
Maximum size gap when reindexing with ``fill_method``.
@@ -7417,13 +7418,13 @@ def resample(self, rule, how=None, axis=0, fill_method=None, closed=None,
74177418
For frequencies that evenly subdivide 1 day, the "origin" of the
74187419
aggregated intervals. For example, for '5min' frequency, base could
74197420
range from 0 through 4. Defaults to 0.
7420-
on : string, optional
7421+
on : str, optional
74217422
For a DataFrame, column to use instead of index for resampling.
74227423
Column must be datetime-like.
74237424
74247425
.. versionadded:: 0.19.0
74257426
7426-
level : string or int, optional
7427+
level : str or int, optional
74277428
For a MultiIndex, level (name or number) to use for
74287429
resampling. ``level`` must be datetime-like.
74297430
@@ -7531,7 +7532,7 @@ def resample(self, rule, how=None, axis=0, fill_method=None, closed=None,
75317532
Pass a custom function via ``apply``
75327533
75337534
>>> def custom_resampler(array_like):
7534-
... return np.sum(array_like)+5
7535+
... return np.sum(array_like) + 5
75357536
75367537
>>> series.resample('3T').apply(custom_resampler)
75377538
2000-01-01 00:00:00 8
@@ -7542,8 +7543,7 @@ def resample(self, rule, how=None, axis=0, fill_method=None, closed=None,
75427543
For a Series with a PeriodIndex, the keyword `convention` can be
75437544
used to control whether to use the start or end of `rule`.
75447545
7545-
>>> s = pd.Series([1, 2], index=pd.period_range(
7546-
... '2012-01-01',
7546+
>>> s = pd.Series([1, 2], index=pd.period_range('2012-01-01',
75477547
... freq='A',
75487548
... periods=2))
75497549
>>> s
@@ -7584,7 +7584,8 @@ def resample(self, rule, how=None, axis=0, fill_method=None, closed=None,
75847584
For DataFrame objects, the keyword ``on`` can be used to specify the
75857585
column instead of the index for resampling.
75867586
7587-
>>> df = pd.DataFrame(data=9*[range(4)], columns=['a', 'b', 'c', 'd'])
7587+
>>> df = pd.DataFrame(data=9 * [range(4)],
7588+
... columns=['a', 'b', 'c', 'd'])
75887589
>>> df['time'] = pd.date_range('1/1/2000', periods=9, freq='T')
75897590
>>> df.resample('3T', on='time').sum()
75907591
a b c d
@@ -7597,7 +7598,7 @@ def resample(self, rule, how=None, axis=0, fill_method=None, closed=None,
75977598
specify on level the resampling needs to take place.
75987599
75997600
>>> time = pd.date_range('1/1/2000', periods=5, freq='T')
7600-
>>> df2 = pd.DataFrame(data=10*[range(4)],
7601+
>>> df2 = pd.DataFrame(data=10 * [range(4)],
76017602
... columns=['a', 'b', 'c', 'd'],
76027603
... index=pd.MultiIndex.from_product([time, [1, 2]])
76037604
... )

0 commit comments

Comments
 (0)