'Python Pandas: sre_constants.error: missing ), unterminated subpattern at position 10
I am trying to iterate a list of strings using dataframe1 to check whether the other dataframe2 has any strings found in dataframe1 to replace them.
for index, row in df.iterrows():
print( row['x1'] )
df2['strings'].str.replace(row['x1'],"")
In order to do this I iterated using the code shown above to check and replace for any string found in df1
wait_timeout
interactive_timeout
pool_recycle
....
__all__
folder_name
re.compile('he(lo') <= error string
However, while iterating it attempts to replace the string re.compile('he(lo') but is unable to as the string has "(()" brackets which are uneven. I have read other discussions that replace uses reg expressions and I can fix it by using /(. So I attempted to use:
replace = row['x1'].str.replace("(","\(")
replace = replace.str.replace(")","\)")
But I received an error on replace = replace.str.replace(")","\)") stating that
AttributeError: 'str' object has no attribute 'str'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
