Apr-27-2017, 04:44 PM
As nilamo said, filter "filters" entire subsets of original dataframe. It is similar to your previous groups attribute of a groupby questions - for every unique value company of Company column your lambda gets the dataframe
Btw,
sales[sales.Company==company]
as an argument, then selects and sums Units column and either keeps entire group (if sum is bigger than 35) or "drop" it. So your result is a dataframe with all companies that sold more than 35 units...Btw,
df.apply()
applies function to entire row or column, applying function to a "cell" holds only if you use apply with pandas serie. Quite often thats interchangeable - if you want to apply function on column of a dataframe, you can use either (trivial example)sales.apply(lambda g: 2 * g['Units'], axis=1) # lambda function used on entire row, selects "column"or
sales.Units.apply(lambda g: 2 *g) # lambda function used on "cell" - column was already selectedUsually second form is preferred.