How To Remove String Value From Column In Pandas Dataframe
I am trying to write some code that splits a string in a dataframe column at comma (so it becomes a list) and removes a certain string from that list if it is present. after removi
Solution 1:
simply you can apply the regex b,?
, which means replace any value of b
and ,
found after the b
if exists
df['Column2'] = df.Column2.str.replace('b,?' , '')
Out[238]:
Column1 Column2
0 a a,c
1 y n,m
2 d n,n,m
3 d x
Post a Comment for "How To Remove String Value From Column In Pandas Dataframe"