Madjid
Madjid

Reputation: 235

cleaning a string in a dataframe column

i have the following column :

enter image description here

i want to remove the link and and any unnecessary symbols i've tried this :

def clean(col) : 
col =  re.sub("http\S*\s", "", col)
return col
PalEng["Content"] = PalEng["Content"].apply(str)
PalEng["Content"] = PalEng["Content"].apply(clean)

it worked for some rows , but the majority didn't change

Upvotes: -1

Views: 69

Answers (1)

Jan
Jan

Reputation: 432

You can get rid of "https://"

yoursting.removeprefix("https://")

Upvotes: 1

Related Questions