Requesting a data frame in Pandas Python
I have a problem requesting a dataframe in panda when I use a variable instead of a value.
df2 = pd.read_csv('my.csv')
query=df2.query('cc_vehicle_line==7')
works fine but
df2 = pd.read_csv('my.csv')
query=df2.query('cc_vehicle_line==variable_name')
It prints the message that variable_name is undefined. But it is defined. I cannot hardcoded the value, since I need to automate and depending on the value of variable_name, select the appropriate rows.
Did I miss something?
thank
+3
source to share