I have a simple 3-column csv file that I need to use python to group each line based on one key, then the average value for the other key and return them. The file is the standard csv format configured in this way;
ID, ZIPCODE, RATE 1, 19003, 27.50 2, 19003, 31.33 3, 19083, 41.4 4, 19083, 17.9 5, 19102, 21.40
So basically I need to calculate the average col [2] rate for each unique col [1] zip code in this file and return the results. So get the average rate for all entries in 19003, 19083, etc.
I looked at using the csv module and reading a file in a dictionary, and then sorting a dict based on unique values ββin zipcode col, but it seems to have made no progress.
Any help / suggestions appreciated.
source share