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
<div class="alert alert-info flex not-prose">![]()
<span class="hidden md:block">Watch a video course</span>Python - The Practical Guide</div>
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.