I'm new to pandas
, trying to create a new column in Pandas Dataframe, and assign a string value based on a function, but the outcome outputs only 1 value ('residential) to all 5,000 columns. Any idea what's wrong with my code? Thank you
def programType(c):
if c['Primary Property Type - Self Selected'] == 'Multifamily Housing' or 'Residence Hall/Dormitory':
return 'Residential'
elif c['Primary Property Type - Self Selected'] == 'Bank Branch' or 'Hotel' or 'Financial Office' \
or 'Retail Store' or 'Distribution Center' or 'Non-Refrigerated Warehouse' or 'Fitness Center/Health Club/Gym' \
or 'Mixed Use Property' or 'Self-Storage Facility' or 'Wholesale Club/Supercenter' or 'Supermarket/Grocery Store':
return 'Commercial'
elif c['Primary Property Type - Self Selected'] == 'Senior Care Community' or 'K-12 School' or 'College/University' \
or 'Worship Facility' or 'Medical Office' or 'Hospital (General Medical & Surgical)':
return 'Institutional'
elif c['Primary Property Type - Self Selected'] == 'Manufacturing/Industrial Plant':
return 'Industrial'
else:
return 'Other'
The new column is called 'Program Type'
datav3['Program Type'] = datav3.apply(programType, axis=1)