I have a list hikari_col which has a two values: column_name1, column_name2.
I also have a dataframe df1 which contains this values as column names.
I'm trying to check a values from df1 dataframe based on that hikari_col list. So I'm passing a values from list in for loop as a column in dataframe and checking if it throws an error or not.
hikari_cols = ["column_name1", "column_name2"]
df1 = create_dfs("hikari", hikari_cols) # creating a df in another function
for hikari_col in hikari_cols: # looping over values in list (same as column names in df1)
try:
df1.hikari_col # Checking if column was created - It is, and its available as `df1.column_name1`
except: # But not as df1.hikari_col
return err_dict = {"error": "not found"}
But it goes to exception every time. What I'm doing wrong?