Generation

generate functionFri, 27 Jan 2023

There is a Pandas dataframe date city hotel total_rooms ocup_rooms revenue oper_costs adv_costs profit 0 2021-07-01 Yalta Rapsodia 33 24 78936 25641 19305 33990 1 2021-07-01 Yalta AquaMania 28 14 51156 21756 16380 13020 3 2021-07-01 Alushta Breeze 36 25 75475 27972 21060 26443 4 2021-07-01 Alushta Moreon 20 17 51091 15540 11700 23851 6 2021-07-02 Yalta Rapsodia 33 27 75276 25641 19305 30330 Write a lambda function with loc method that filters out all data and leaves only revenue > 40000 and total_rooms < 30

df.loc[lambda x: (x['revenue'] > 40000) & (x['total_rooms'] < 30)]

Questions about programming?Chat with your personal AI assistant