I have a pandas dataframe like this:
Index Resource
2020-07-15 11:59:02 Monkey
2020-07-16 11:59:02 Helicopter
2020-07-17 11:59:02 Forklift
2020-07-18 11:59:02 Airplane
2020-07-19 11:59:02 Dinosaur
2020-07-20 11:59:02 Drone
2020-07-20 11:59:02 Truck
2020-07-20 11:59:02 Airplane
2020-07-22 11:59:02 Truck
2020-07-22 11:59:02 Transport
2020-07-23 11:59:02 Dozer
2020-07-24 11:59:02 Patrol
2020-07-25 11:59:02 Dinosaur
And I want to add a new column named 'Category' like this:
Index Resource Category
2020-07-15 11:59:02 Monkey Other
2020-07-16 11:59:02 Helicopter Aviation
2020-07-17 11:59:02 Forklift Equipment
2020-07-18 11:59:02 Airplane Aviation
2020-07-19 11:59:02 Dinosaur Other
2020-07-20 11:59:02 Drone Aviation
2020-07-20 11:59:02 Truck Equipment
2020-07-20 11:59:02 Airplane Aviation
2020-07-22 11:59:02 Truck Equipment
2020-07-22 11:59:02 Transport Crew
2020-07-23 11:59:02 Dozer Equipment
2020-07-24 11:59:02 Patrol Crew
2020-07-25 11:59:02 Dinosaur Other
...possibly based upon whether the value of 'Resource' is found in the following lists or not:
aviation_list = ['Airplane', 'Helicopter', 'Drone', 'Parachute']
equipment_list = ['Truck', 'Dozer', 'Forklift', 'Excavator']
crew_list = ['Transport', 'Patrol', 'Stationary']
So the value of the new column 'Category' will default to 'Other' if the value of 'Resource' isn't found in the defined lists; otherwise 'Category' gets 'Aviation', 'Equipment', or 'Crew' respectively. (Each 'Resource' belongs to only one 'Category'.)
I'm sure there must be an elegant way to do this in pandas. Can anyone offer advice?