I am new to pandas, I am facing issue with adding df to a string. so I have a conditional string statement like this "'bikes'>20"
, where bikes are the column name in a data frame. Now I want to add df before 'bikes', How do I do it? I have used this code below but it is not working
my code:
x="'bikes'> 20"
x = re.sub(r"([> =!<]==)", r'df[\1]', x)
this gives: 'bikes'> 20
but not adding the df
Want I want is: df['bikes']>20
Is there any way to do it?