Python: Failed in retrieving the highest amount from a repeated data with different amount in a certain year
问题 The csv file that I have contain several repeated supplier_name but with different amt for year 2015-2017. Here goes my codes. df = pd.read_csv('government-procurement-via-gebiz.csv', parse_dates=['award_date'], infer_datetime_format=True, usecols=['supplier_name', 'award_date', 'awarded_amt'],) df = df[(df['supplier_name'] != 'na') & (df['award_date'].dt.year == 2015)].reset_index(drop=True) d1 = df.set_index('supplier_name').to_dict()['awarded_amt'] top5D1 = dict(sorted(d1.iteritems(), key