* re-written *

Hi there, I would like to loc a dataframe using a string variable that is equal to a function

something like:

str_A = "df[\'column_name\'].isna()"  


this should give me the portion of the df where "column_name" values are not NaN.

Unfortunately Python reads "str_A" as a column label and not as a function,

so it returns an error: "label [df['column_name'].isna()] is not present into df"

The reason I am doing this is to be able to concatenate several functions into a string in order to automate the slicing of the df.

Any hint?

0 Answers