Categories
Python Answers

How to get a frequency count based on two columns (variables) in Pandas data frame some row appears with Python?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *