I have a column "APNT_NA_ACTN" that provides the type of coding used to hire employees:
115, 515, 100, 786, 101, etc...
I have aliased my set of data as names, therefore names[:3] provides three rows of the entire set.
I have the ability to filter one type of code:
names[names['APNT_NA_ACTN'] == 115]
names
but, I want to filter only: 115 and 515 from this column. I've tried the following
temp = names[(names['APNT_NA_ACTN'] == 115) & (names['APNT_NA_ACTN'] == 515)]
temp
and I have also tried:
temp = names.query('[100,515] in 'APNT_NA_ACTN')
can anyone offer assistance?
thanks
so in all both suggestions below worked for me:
1) temp = names[names['APNT_NA_ACTN'].isin([115,515])]
2) hiring_code = names['APNT_NA_ACTN'] temp = names[(hiring_code == 115) | (hiring_code == 515)] temp[['NM_EMP_LST','NAT_ACTN_2_3','ACTN_YMD','ORG_LEV2','ORG_LEV3','APNT_NA_ACTN','APNT_YMD','SCD_LV_YMD','SSNO','year']]
names['APNT_NA_ACTN'].isin([115,515)]names['APNT_NA_ACTN'].isin([115,515])]