@@ -320,7 +320,79 @@ def aggregate(self, arg, *args, **kwargs):
320
320
agg = aggregate
321
321
322
322
_shared_docs ['sum' ] = dedent ("""
323
- %(name)s sum""" )
323
+ Calculate %(name)s sum of given DataFrame or Series.
324
+
325
+ Parameters
326
+ ----------
327
+ *args, **kwargs
328
+ For compatibility with other %(name)s methods. Has no effect
329
+ on the computed value.
330
+
331
+ Returns
332
+ -------
333
+ Series or DataFrame
334
+ Same type as the input, with the same index, containing the
335
+ %(name)s sum.
336
+
337
+ See Also
338
+ --------
339
+ Series.sum : Reducing sum for Series.
340
+ DataFrame.sum : Reducing sum for DataFrame.
341
+
342
+ Examples
343
+ --------
344
+ >>> s = pd.Series([1, 2, 3, 4, 5])
345
+ >>> s
346
+ 0 1
347
+ 1 2
348
+ 2 3
349
+ 3 4
350
+ 4 5
351
+ dtype: int64
352
+
353
+ >>> s.rolling(3).sum()
354
+ 0 NaN
355
+ 1 NaN
356
+ 2 6.0
357
+ 3 9.0
358
+ 4 12.0
359
+ dtype: float64
360
+
361
+ >>> s.expanding(3).sum()
362
+ 0 NaN
363
+ 1 NaN
364
+ 2 6.0
365
+ 3 10.0
366
+ 4 15.0
367
+ dtype: float64
368
+
369
+ >>> s.rolling(3, center=True).sum()
370
+ 0 NaN
371
+ 1 6.0
372
+ 2 9.0
373
+ 3 12.0
374
+ 4 NaN
375
+ dtype: float64
376
+
377
+ For DataFrame, each %(name)s sum is computed column-wise.
378
+
379
+ >>> df = pd.DataFrame({"A": s, "B": s ** 2})
380
+ >>> df
381
+ A B
382
+ 0 1 1
383
+ 1 2 4
384
+ 2 3 9
385
+ 3 4 16
386
+ 4 5 25
387
+
388
+ >>> df.rolling(3).sum()
389
+ A B
390
+ 0 NaN NaN
391
+ 1 NaN NaN
392
+ 2 6.0 14.0
393
+ 3 9.0 29.0
394
+ 4 12.0 50.0
395
+ """ )
324
396
325
397
_shared_docs ['mean' ] = dedent ("""
326
398
%(name)s mean""" )
@@ -640,7 +712,6 @@ def aggregate(self, arg, *args, **kwargs):
640
712
agg = aggregate
641
713
642
714
@Substitution (name = 'window' )
643
- @Appender (_doc_template )
644
715
@Appender (_shared_docs ['sum' ])
645
716
def sum (self , * args , ** kwargs ):
646
717
nv .validate_window_func ('sum' , args , kwargs )
@@ -1326,7 +1397,6 @@ def apply(self, func, args=(), kwargs={}):
1326
1397
return super (Rolling , self ).apply (func , args = args , kwargs = kwargs )
1327
1398
1328
1399
@Substitution (name = 'rolling' )
1329
- @Appender (_doc_template )
1330
1400
@Appender (_shared_docs ['sum' ])
1331
1401
def sum (self , * args , ** kwargs ):
1332
1402
nv .validate_rolling_func ('sum' , args , kwargs )
@@ -1588,7 +1658,6 @@ def apply(self, func, args=(), kwargs={}):
1588
1658
return super (Expanding , self ).apply (func , args = args , kwargs = kwargs )
1589
1659
1590
1660
@Substitution (name = 'expanding' )
1591
- @Appender (_doc_template )
1592
1661
@Appender (_shared_docs ['sum' ])
1593
1662
def sum (self , * args , ** kwargs ):
1594
1663
nv .validate_expanding_func ('sum' , args , kwargs )
0 commit comments