From the course: Exploring Data Science with .NET using Polyglot Notebooks & ML.NET

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Grouping data

Grouping data

- [Instructor] When you're performing data analysis, you'll often want to be able to group your data by certain columns. For example, if we wanted to analyze information at the region level or at the product category level, well, we can do that with a data frame. So here I'll add a column, and I'm going to say, df.groupBy, and I'm going to give it the name of the column I want to group by. In this case, it's going to be the region. This gives me a list of groups which is not exactly helpful. But what I can do with this, is I can actually go in here and I can say, "Hey, I want to get a sum of some columns." So let's summarize the, let's say, the total that we get per region and let's sum the quantity, and let's also sum the price. And now, I see I have my sales broken down by different region, where I see the total per region, the quantity per region, and the price per region. So that's grouping by at a very simple level. Let's see that again with a slightly different behavior. So…

Contents