I am attempting to write a specific value to a column in a pandas df depending on if another column does or does not contain certain text. I have 3 outputs in the destination columns: Distributor
, OEM
and End User
.
import pandas as pd
df = pd.read_excel("Customer Records.xlsx")
#Checking for distributor pricing tag
df.loc[df['CustomerRoles'].str.contains('Discount-Distributor-STD'), 'Customer Type'] = 'Distributor'
#Checking for OEM pricing tag
df.loc[df['CustomerRoles'].str.contains('Discount-OEM-STD'), 'Customer Type'] = 'OEM'
Those lines of code work as intended.
The last thing I need is for every other string that contains neither of those phrases to print "End User"
in the 'Customer Type'
column.