How to get equivalent of pandas.DataFrame.pivot_table
See original GitHub issueHow to get equivalent of pandas.DataFrame.pivot_table like here
table = pivot_table(df, values=['D', 'E'], index=['A', 'C'], aggfunc={'D': np.mean, 'E': [min, max, np.mean]})
Output:
D E
mean max median min
A C
bar large 5.500000 16 14.5 13
small 5.500000 15 14.5 14
foo large 2.000000 10 9.5 9
small 2.333333 12 11.0 8
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
How to Convert Pandas Pivot Table to DataFrame - Statology
You can use the following syntax to convert a pandas pivot table to a pandas DataFrame: df = pivot_name.reset_index().
Read more >pandas.pivot_table — pandas 1.5.2 documentation
Create a spreadsheet-style pivot table as a DataFrame. The levels in the pivot table will be stored in MultiIndex objects (hierarchical indexes) on...
Read more >A Guide to Pandas Pivot Table - Built In
Download or import the data that you want to use. · In the pivot_table function, specify the DataFrame you are summarizing, along with...
Read more >pandas pivot table to data frame - python - Stack Overflow
Your original dataframe does not have header "patient". Where does it come from? – DYZ. Mar 10, 2017 at 1:19.
Read more >Pandas Pivot Table Explained - Practical Business Python -
The simplest pivot table must have a dataframe and an index . In this case, let's use the Name as our index. pd.pivot_table(df...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, just to let you know I’ve upgraded the Data-Forge pivot function to support multiple outputs so that you can use it more like Pandas.
So now with Data-Forge 1.0.9 you can do your pivot like this:
For an example please see the unit test pivot can produce multiple output values in the pivot tests file.
You also asked for multi-level indexes and columns (like Pandas), but at the moment I’m not planning on implementing this feature for Data-Forge. I’m afraid it’s going to stay in the too-hard basket for the forseeable future.
Great!
You might also be interested know that I’m writing a book on this type of thing.
Please take a look: http://bit.ly/2t2cJu2