Hi all, The problem is related to the Python backlash error. I am creating a dynamic query string for filtering in pandas. The code is:
filters = dict(wlbWellType=['EXPLORATION'])
query_string = ''
index = 0
for (k,v) in filters.iteritems():
for i in v:
if (index == 0):
query_string += '"{}"'.format((k) + ' == '+"'{}'".format(i))
else:
query_string += ' & ' '"{}"'.format((k) + ' == ' +
"'{}'".format(i))
index += 1
If I do "print query_string" the output I got is
"wlbWellType == 'EXPLORATION'"
If I do "query_string" the output I got is
'"wlbWellType == \'EXPLORATION\'"'
I want
"wlbWellType == 'EXPLORATION'"
as the output without using print statement. Seems there is an error related to backlash.
The query_string output will then be used as:
df.query(query_string)
Can anyone please help me with the above problem?
Thanks in advance
filtersDF/Series?