Skip to content

Commit 3329d37

Browse files
committed
Fix docs to use correct pivot_table arguments [pandas-dev#6645, pandas-dev#5505]
1 parent fa8a35c commit 3329d37

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

doc/source/comparison_with_r.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ In ``pandas`` we may use :meth:`~pandas.pivot_table` method to handle this:
171171
'player': random.sample(list(string.ascii_lowercase),25),
172172
'batting avg': np.random.uniform(.200, .400, 25)
173173
})
174-
baseball.pivot_table(values='batting avg', cols='team', aggfunc=np.max)
174+
baseball.pivot_table(values='batting avg', columns='team', aggfunc=np.max)
175175
176176
For more details and examples see :ref:`the reshaping documentation
177177
<reshaping.pivot>`.
@@ -402,8 +402,8 @@ In Python the best way is to make use of :meth:`~pandas.pivot_table`:
402402
'week': [1,2]*6
403403
})
404404
mdf = pd.melt(df, id_vars=['month', 'week'])
405-
pd.pivot_table(mdf, values='value', rows=['variable','week'],
406-
cols=['month'], aggfunc=np.mean)
405+
pd.pivot_table(mdf, values='value', index=['variable','week'],
406+
columns=['month'], aggfunc=np.mean)
407407
408408
Similarly for ``dcast`` which uses a data.frame called ``df`` in R to
409409
aggregate information based on ``Animal`` and ``FeedType``:
@@ -433,7 +433,7 @@ using :meth:`~pandas.pivot_table`:
433433
'Amount': [10, 7, 4, 2, 5, 6, 2],
434434
})
435435
436-
df.pivot_table(values='Amount', rows='Animal', cols='FeedType', aggfunc='sum')
436+
df.pivot_table(values='Amount', index='Animal', columns='FeedType', aggfunc='sum')
437437
438438
The second approach is to use the :meth:`~pandas.DataFrame.groupby` method:
439439

0 commit comments

Comments
 (0)