2 ms·
There's a nice NumPy-based Python package called Tabular (http://www.parsemydata.com/tabular/index.html http://www.parsemydata.com/tabular/index.html) that make
by skept 16y ago
There's a nice NumPy-based Python package called Tabular (http://www.parsemydata.com/tabular/index.html http://www.parsemydata.com/tabular/index.html) that makes this super easy:
import numpy as np
import tabular
# CSV with Region, City and Sales columns
data = tabular.tabarray(SVfile = 'data.csv')
# Calculate the total sales within each region
summary = data.aggregate(On = ['Region'], AggFuncDict = {'Sales':np.sum}, AggFunc = len)
summary.saveSV('summary.csv')