I have a dataframe 'df1' with a string column 'Field_notes' of various information that looks like this:
Alt_ID | Field_notes |
---|---|
JMs # 04J0342 | |
JMs # 04J0343 | |
JMs # 04J0344 | |
# broken leg | |
54.2 | |
JMs # 04J0345 |
I would like to extract parts of the strings from the "Field_notes" column for specific rows only to the "Alt_ID" column. In this case, I'd like to subset rows 1,2,3,6 so that the alphanumeric combination after "JMs # " is moved to the "Alt_ID" column, so the result looks like:
Alt_ID | Field_notes |
---|---|
04J0342 | JMs # 04J0342 |
04J0343 | JMs # 04J0343 |
04J0344 | JMs # 04J0344 |
# broken leg | |
54.2 | |
04J0345 | JMs # 04J0345 |
The tricky part is that there are so many combinations of information in Field_notes that I probably can't rely on character patterns and instead have to rely on specifying row names/numbers. In this case, I don't want to extract anything from '# broken leg'.