Python - Grouping by multiple columns and getting max or sum
问题 I am interested in getting max value of the Product price. Here is the input data.Download Sales Data I want to group by State,Country How do I go about grouping these two columns get the max value of Price. import csv import locale from itertools import groupby locale.setlocale( locale.LC_ALL, 'en_US.UTF-8' ) total_price = 0 max_price = 0 reader = csv.DictReader(open('/Users/myuser/Downloads/SalesData.csv', 'rU'), dialect='excel') groups = groupby(reader, lambda d: d['State']) result = [max