Reputation: 4442
I need to find in dataframe some strings
url
003.ru/*/mobilnyj_telefon_bq_phoenix*
003.ru/*/mobilnyj_telefon_fly_*
003.ru/*mobile*
003.ru/telefony_i_smartfony/mobilnye_telefony_smartfony
003.ru/telefony_i_smartfony/mobilnye_telefony_smartfony/%brands%5D%5Bbr_23%
1click.ru/*iphone*
1click.ru/catalogue/chasy-motorola
problen in next: when I use
df_update = df[df['url'].str.contains(substr.url)]
it return error, because some url
contain *
.
How can I fix that problem?
Upvotes: 1
Views: 3800
Reputation: 13274
Try:
df[df['url'].str.contains(substr.url, regex=False)]
You have to specify whether or not you want your pattern to be interpreted as a regular expression or a normal string. In this case, you want to set the regex
argument to False
because it is set to True
by default. That way, the asterisks in your pattern won't be interpreted as regular expression.
I hope this helps.
Upvotes: 3