How do I find the most common first name from the column 'First Name' of my data set.
I have previously tried to use the mode function, however it was unfortunately not working. I am unsure what to do please help thank you very much.
I would do:
first_names = df['First Name']
most_common_name = first_names.value_counts().idxmax()
where df
is a dataframe from a csv file, something you created on your own, etc.
Using mode
wouldn't work because that would give you the mode of each column rather than a single one that you're looking for. Using value_counts
would give you a specific count of how many times values appear in a specific column. Put that with idmax
and it will only provide you the most common column value.