FAQ: Aggregates in Pandas - Calculating Aggregate Functions II

In this example id is the name of a column. Pandas has a convenience option to use the . attribute syntax for column names in most circumstances (but not all).

In this case teas.groupby('category').id == teas.groupby('category')['id'] or more generally teas.id == teas['id']. Sometimes that syntax can be preferable or more readable, in other cases it may be more confusing.

Might be useful reading at this Q/A on the . dotted attribute syntax in pandas-

1 Like