I have a pandas dataframe, combined_copy which has a column, job_industry_category with multiple categories. I want to use a mapping function to restrict these categories to the top 3 by distribution, the rest form one other category. I intend to use numeric digits as follows:
combined_copy['job_industry_category'].map({'Manufacturing' : 0, 'Financial Services' : 1, 'Health' : 2})
I need help on how to map all the other remaining categories into a class 3, as one category.
The list of all categories in this column is as follows: ['Manufacturing', 'Financial Services', 'Not Specified', 'Health', 'Retail', 'Property', 'IT', 'Entertainment', 'Argiculture', 'Telecommunications']
I have tried using the na_action argument:
combined_copy['job_industry_category'].map({'Manufacturing' : 0, 'Financial Services' : 1, 'Health' : 2}, na_action={None : 3})
but the other category appears as NaNs. Please kindly assist.