Selecting the sum of a column's value from a SQL table, translated to Python's pandas.

Selecting a single column's sum of values

In SQL:

SELECT 
  SUM(column_1) 
FROM 
  table;

In pandas:

table['column_1'].sum()

Selecting the sum of multiple columns

In SQL:

SELECT 
  SUM(column_1), 
  SUM(column_2) 
FROM 
  table;

In pandas:

table
    .agg({'column_1': ['sum'], 'column_2': ['sum']})

Selecting the sum of columns with an alias

In SQL:

SELECT 
  column_1, 
  SUM(column_2) AS sum_alias_1, 
  SUM(column_3) AS sum_alias_2 
FROM 
  table 
GROUP BY 
  column_1;

In pandas:

table 
    .groupby('column_1') 
    .agg(sum_alias_1=('column_2', 'sum'), sum_alias_2=('column_3', 'sum')) 

References