Example data
Data
[Type] [Cert Code] [Cert Desc] [Data Source]
HP X1 Logic Vendor
BA X2 Disc Employee
mappingID
[Cert Code] [Cert Desc]
X3 Logic
X4 Disc
So X1 becomes X3 in data
I have this pandas code below which changes Certification Code to Old Certification Code based on description mappings in a second data frame.
The problem is I want to set two conditions whereby it does this only for rows with ‘vendor’ in ‘data source’ column and ‘hp’ in ‘type’ column. Can anyone help?
data['Certification Code'] = data['Certification Description'].map(mappingID.set_index('NEW Certification Description')['OLD Certification Code'])
I tried
filter = data[(data.Vendor == 'HP') & (data['Data Source'] == 'Vendor')]
I get
Data
[Type] [Cert Code] [Cert Desc] [Data Source]
HP X3 Logic Vendor
BA Disc Employee
data['Certification Code'] = filter['Certification Description'].map(mappingID.set_index('NEW Certification Description')['OLD Certification Code'])
The problem here it turns the Certification Code to blank for the other Vendors in the list.
Desired Outcome
Data
[Type] [Cert Code] [Cert Desc] [Data Source]
HP X3 Logic Vendor
BA X2 Disc Employee