I have a dataframe df with only one column which have strings like: 005f12b33ac4bdb310d8e503a065ef10b28566ea#code_id#alarm|clock
I want to remove the ending of the string starting from #code_id# and want the string to look like 005f12b33ac4bdb310d8e503a065ef10b28566ea
How can I do it?
CodePudding user response:
Try this :
df['Column_name']= df['Column_name'].astype(str).str.split('#').str[0]
CodePudding user response:
Use:
df['col'] = df['col'].str.extract('(.*)#code_id#')
