Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get equivalent of pandas.DataFrame.pivot_table? #94

Open
pikhovkin opened this issue May 21, 2018 · 0 comments
Open

How to get equivalent of pandas.DataFrame.pivot_table? #94

pikhovkin opened this issue May 21, 2018 · 0 comments

Comments

@pikhovkin
Copy link

How to get equivalent of pandas.DataFrame.pivot_table like here?

table = pivot_table(df, values='D', index=['A', 'B'], columns=['C'], aggfunc=[np.sum])

Input:

>>> df
     A    B      C  D
0  foo  one  small  1
1  foo  one  large  2
2  foo  one  large  2
3  foo  two  small  3
4  foo  two  small  3
5  bar  one  large  4
6  bar  one  small  5
7  bar  two  small  6
8  bar  two  large  7

Output:

C        large  small
A   B
bar one    4.0    5.0
    two    7.0    6.0
foo one    4.0    1.0
    two    NaN    6.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant