Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """
- 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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement