I was trying to solve the practice exercise here - Pandas - Inner Merge
The question is:
Cool T-Shirts Inc. wants to know the months when they crushed their targets.
Select the rows from
revenue is greater than
target . Save these rows to the variable
I answered like this
crushing_it = sales_vs_targets.apply(sales_vs_targets.revenue > sales_vs_targets.target) but it was wrong.
The correct solution is:
crushing_it = sales_vs_targets[sales_vs_targets.revenue > sales_vs_targets.target]
From what I understand, .apply() can be used to perform operations on a dataframe, so I am not sure why my answer is wrong. May I ask… when should I use .apply() to perform operations then? Appreciate an explanation.
Example of .apply()
Thanks and cheers!