Sometimes, we want to get a frequency count based on two columns (variables) in Pandas data frame some row appears with Python.
In this article, we’ll look at how to get a frequency count based on two columns (variables) in Pandas data frame some row appears with Python.
How to get a frequency count based on two columns (variables) in Pandas data frame some row appears with Python?
To get a frequency count based on two columns (variables) in Pandas data frame some row appears with Python, we can use the size
method.
For instance, we write
df.groupby(["Group", "Size"]).size()
to call groupby
to group data by the Group and Size columns in the df
data frame.
Then we call size
to get the size of each group.
Conclusion
To get a frequency count based on two columns (variables) in Pandas data frame some row appears with Python, we can use the size
method.