Asked By: Anonymous
I have a dataset, df, where I would like to separate strings within Python.
Type Id aa - generation aa - generation01 aa_led - generation aa_led - generation01 ss - generation ss- generation01
Type Id aa aa01 aa_led aa_led01 ss ss01
I am trying to incorporate this code into my script, however, this splits by hyphen but my column
names are not reserved.
new = wordstring.strip('-').split('-')
Any suggestion is appreciated
Answered By: Anonymous
If you just want to remove
generation from every value in df. You can use
df = df.applymap(lambda x : x.replace('- generation', '').replace(' ',''))
Type Id 0 aa aa01 1 aa_led aa_led01 2 ss ss01