I have a bunch of categorical, part of speech data that I want to collapse into fewer categories. np.where() won't do because I want to have 6 categories at the end: noun, verb, adjective, adverb, preposition, and other.
I've found out that I can use pandas.replace() in combination with a dictionary to do this.
So, I've made the following dictionary:
mappings = {"NN" : "noun", "NNS" : "noun", "NNP" : "noun",
"VB" : "verb", "VBD" : "verb", "VBG" : "verb", "VBN" : "verb", "VBP" : "verb", "VBZ" : "verb",
"JJ" : "adj", "JJR" : "adj", "JJS" : "adj",
"RB" : "adv", "RBR" : "adv", "RBS" : "adv",
"IN" : "prep"}
The problem is, there are a LOT more parts of speech present in the data. Is there a way for me to shove all of those other parts of speech into an "other" category, or will I have to manually type in all of the other possible parts of speech?