-
-
Save hute37/09ff79aeb03a419a5d250eb2aa947e6b to your computer and use it in GitHub Desktop.
This file contains hidden or 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