Last active
July 9, 2019 06:31
-
-
Save pemagrg1/c59d4291d4165c6d7e6ee8891b782d13 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
""" | |
Get total of each column values | |
""" | |
def totalcount(data): | |
return data.assign(Total=data.drop('Total', errors='ignore', axis=1).sum(1)) | |
def pandas_get_total_row(df): | |
df = df.pipe(totalcount).T.pipe(totalcount).T | |
return df | |
df = pd.read_csv("<path to csv>") | |
df = pandas_get_total_row(df) | |
print(df) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment