I'm trying to consolidate the strings below for lack of a better term - I would like to identify all examples of "BB" and change them to "BB", same for all examples of "B" to "B" and the same for all CCC examples to make all categories uniform. Below is the list of all unique examples in the list:
array(['BB+', 'B-', 'BB', 'BB-', 'CCC+', 'N.A.', 'CCC', 'B+', 'B', None,
'BB *-', 'B- *+', 'CC *-', 'B+ *-', 'BB- *-', 'NR', 'CCC-', 'BBB-',
'B+ *+', 'BB+ *+', 'B *+', 'BB *+', 'D', 'BB+ *-', 'CCC+ *+',
'BBB', 'C *-', 'CCC+ *-', 'BB- *+', 'CCC *+', 'FLD UNKNO',
'(P)CCC+', '(P)B+', 'C', 'CCC- *-', 'BBB- *-'], dtype=object)
So for example, all 'BB+' would be changed to 'BB'
Same for examples like 'BB+ *+' would be converted to just 'BB'
I had been using
.str.find('BB').replace(0,'BB')
On the particular column of the dataframe, but the problem is all of the B+/-/flat and CCC examples are identified as -1 so I can't differentiate from there.
The ideal output would be:
BB+, BB, BB-, any iteration of those with *+, *-, (P), etc would output to BB
B+, B, B-, any iteration of those *+, *-, (P), etc would output to B
CCC+, CCC, CCC- any iteration of those with *+, *-, (P) would output to CCC