import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import pandas as pd
names_data = pd.read_csv('../input/NationalNames.csv')
frequent_names = names_data[names_data['Count'] > 1000]
indexed_names = frequent_names.set_index(['Year', 'Name'])['Count']
def ambiguity_measure(grouped_frame):
    return 2 * (1 - grouped_frame.max() / grouped_frame.sum())
ambiguity_data = ambiguity_measure(indexed_names.groupby(level=['Year', 'Name']))
yearly_ambiguity = ambiguity_data.groupby(level='Year')