Hi. I am trying to create a pie chart where I group those who have been Covid19 vaccine injured according to their region in the US. The first step is to define the function. This is what I did.
## Create a pie chart representing the state where the COVID19 vaccinated lived following their Adverse Reaction
## Define parameters
### define function to create custom intervals
def region(state):
if state == 'CT' & 'DE' & 'GA' & 'ME' & 'MD'& 'MA' & 'NH' & 'NJ' & 'NY' & 'NC' & 'OH' & 'PA' & 'RI' & 'SC' & 'VA' & 'WV' & 'VT':
return "EST"
elif state == 'FL' & 'IN' & 'KY' & 'MI' & 'TN':
return "Mix of EST & CST"
elif state == 'AL'& 'AK' & 'IL' & 'IA' & 'LA' & 'MN' & 'MS' & 'MO' & 'OK' & 'WI':
return "CST"
elif state == 'TX' & 'KS' & 'NE' & 'ND' & 'SD':
return "Mix of CST & MST"
elif state == 'CO' & 'MT' & 'NM' & 'UT' & 'WY' & 'AZ':
return "MST"
elif state == 'ID' & 'OR':
return "Mix of MST & PST"
elif state == 'CA' & 'WA':
return "PST"
else:
return "All other states & US territories"
### create new column with customized intervals
covid_vaers_cardio["time_zones"] = covid_vaers_cardio["STATE"].apply(region)
covid_vaers_cardio["time_zones"].value_counts()
Error message: unsupported operand type(s) for &: ‘str’ and ‘str’
Seems that I cannot put multiple strings to define a function