pandas sum 1

pandas sum

import pandas as pd

data = {'Month': ['Jan ','Feb ','Mar ','Apr ','May ','Jun '],
        'Bill Commission': [1500,2200,3500,1800,3000,2800],
        'Maria Commission': [3200,4100,2500,3000,4700,3400], 
        'Jack Commission': [1700,3100,3300,2700,2400,3100]
        }

df = pd.DataFrame(data,columns=['Month','Bill Commission','Maria Commission','Jack Commission'])
sum_column = df.sum(axis=0)
print (sum_column)

Here is what the above code is Doing:
1. We create a dictionary with the data we want to put in the table.
2. We create a DataFrame object and pass it the data dictionary and the column names.
3. We use the sum() method to sum the values of each column.
4. We print the sum of each column.

Similar Posts