Loading tutorials
groupby method answers these questions with one idea, called split-apply-combi5 min readgroupby, what object it returns, and how that object becomes a result. It assumes you can build a DataFrame, select columns with df["col"], and read a Series with its index. The previous chapter introduced split-apply-combine. Here you run it.3 min readgroupby call depends on this choice, and most surprising results trace back to it. This chapter covers the forms a key can take and how each one shapes the result.5 min readdf.groupby("region") create a GroupBy object. Here you will use the built-in aggregation methods on that object, see how they treat missing values and column 4 min readgroupby(...)[col].sum() form from the earlier chapters. Here you will learn two methods that look alike but answer different questions: size and count.5 min readgroupby(...).sum() answers one question. Most summary tables need several answers per group: a total, an average, a count of distinct items. The agg method (short for aggregate) computes them in one call. This chapter covers its input forms, how each shapes the result, and how named a4 min readgroupby examples, know what a Series and an index are, and can select columns from a DataFrame. Here you will learn where the group keys end up in the result, and how to put them where you want them.4 min readgroupby(...).sum(). It also 4 min readget_group, and checking how many groups there are and which rows bel5 min readgroupby(...)[col].sum() as covered earlier. It also assumes you know that a pandas Series carries an index. Here you will learn how transform returns group-level results while keeping the original rows, and when to use it in5 min readgroupby(...).agg(...) call. It also assumes you know the earlier chapters' point that agg returns one row per group and transform returns one row per original row. filter is the third shape: it returns original 5 min readapply is the general-purpose method on a GroupBy object. It runs a function of your own on each group and then works out how to combine the results. This chapter assumes you can already use groupby with built-in aggregations, agg, transform, and filter, and that you know the difference bet4 min readgroupby with sum and agg. It also assumes you know what a DatetimeIndex is and have seen pd.to_datetime. If those are new, review them first.4 min readcategory dtype, and how the observed parameter controls which groups appear in the result. It assumes you can already build a DataFrame, select columns, and use groupby with sum, mean, and size. It also assumes you kn5 min readagg, transform, filter, apply, as_index, and dropna from the earlier chapters. Examples target pandas 2.x. Where pandas 3.0 changes a default, the text says so.5 min read