Below I am using a filter with a lambda expression. Up until now, in my course, the "g" in lambda referred to a specific cell in a data frame. For instance, by_company.apply(lambda x: x*2). How does it recognize that it's supposed to be looking at the 'Units' column if g refers to a specific cell? I didn't know you could filter on a cell to obtain a column. I assume this may relate to my previous question about groupby objects.
1 2 |
by_company = sales.groupby( 'Company' ) by_company. filter ( lambda g:g[ 'Units' ]. sum () > 35 ) |