text_plain_output_1.png image_output_1.png
import pandas as pd

import math
import pandas as pd
names_data = pd.read_csv('../input/NationalNames.csv')
frequent_names = names_data[names_data['Count'] > 500]
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']))
names_vs_years = ambiguity_data.unstack(level='Year')
yearly_ambiguity = ambiguity_data.groupby(level='Year')

potentially_ambiguous_names = names_vs_years[(names_vs_years > 0).any(axis=1)]
potentially_ambiguous_names.transpose().plot(figsize=(20, 10))