Why can we get combined column from f500?

HI all, at the last line, for my understanding, table name.loc[column] is the method to take the whole column from table name. but we did not add “combined” column to f500, then how does ‘big_rev_neg_profit=f500.loc[combined]’ return the rows and columns that meet the criteria?


large_revenue=f500.loc[:,‘revenues’]>100000 returns a boolean with True and False values.
This negative_profits=f500.loc[:,‘profits’]<0 returns another boolean with True and False values.
This large_revenue & negative_profits uses the pandas logic operator &, return True when the respective values of large_revenue and negative_profits are True. If any of the value is False, the & would return False. The value of this new boolean series (a combination of the large_revenue and negative_profit boolean series) is stored in combined.

big_rev_neg_profit=f500.loc[combined] The combined boolean series only returns the rows/index of f500 where the boolean series is True.

thank you!! got it now!

1 Like