Count the frequency that a value occurs in a dataframe column
Here is an example code snippet that counts the frequency of values in a column of a Pandas DataFrame:
Here is an example code snippet that counts the frequency of values in a column of a Pandas DataFrame:
Count the frequency of values in a column of a Pandas DataFrame in Python
python— editable, runs on the server
Info
Watch a video course: Python - The Practical Guide
This will output:
output
1 3
2 3
3 3
Name: A, dtype: int64You can also use .value_counts(normalize=True) to get the frequency as a percentage.