I have pandas df with a column containing comma-delimited characteristics like so:
Shot - Wounded/Injured, Shot - Dead (murder, accidental, suicide), Suicide - Attempt, Murder/Suicide, Attempted Murder/Suicide (one variable unsuccessful), Institution/Group/Business, Mass Murder (4+ deceased victims excluding the subject/suspect/perpetrator , one location), Mass Shooting (4+ victims injured or killed excluding the subject/suspect
I would like to split this column into multiple dummy-variable columns, but cannot figure out how to start this process. I am trying to split on columns like so:
df['incident_characteristics'].str.split(',', expand=True)
This doesn't work, however, because there are commas in the middle of descriptions. Instead, I need to split based on a regex match of a comma followed by a space and a capital letter. Can str.split take regex? If so, how is this done?
I think this Regex will do what I need:
,\s[A-Z]
[Shot - Wounded/Injured] , [Shot - Dead (murder, accidental, suicide)] , [Suicide - Attempt, Murder/Suicide]- Parseltongue\s*,\s*(?=[A-Z])- Wiktor Stribiżew