Created
May 6, 2020 07:35
-
-
Save aniruddha27/c712cd68b5b0bbff1422b9869b14c2ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#displays the subtotal using margins and margins_name | |
# margins is a boolean field that should be made True if total values need to be printed. | |
# margins_name is the optional field where you can name the margin row/column in your grouped table. | |
table = pd.pivot_table(df,index=['Sex'],columns=['Pclass'],values=['Survived'],aggfunc=np.sum, margins=True, margins_name='Total_Survived') | |
table |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment