I have one data set in the column "Tags" I would like to remove in each cell from the world "importacion" to the "," and in some cases, it is just alone without the ",":
"importacion-2022-04-20-10:35:20, curioso, new user,lead_player,female,view_snapshot_cinnabon,like_cinnabon,view_legals_cinnabon,view_snapshot_moneypool,view_snapshot_la borra del café,view_snapshot_galt energy,like_la borra del café,view_snapshot_mccarthy's irish pub,like_mccarthy's irish pub,view_snapshot_la cervecerÃ\xada de barrio,like_la cervecerÃ\xada de barrio"
df["Tags"]=df.Tags.apply(lambda x: x.split(',') x[0].replace('') if x=='importacion' else pass )
obviously its not working.
CodePudding user response:
You might be able to just use str.replace
here:
df["Tags"] = df["Tags"].str.replace(r'^importacion.*,\s*', '', regex=True)