When my dataset contains all the variables, I can create a subset by selecting just the variables I need. But If one if missing I got Nothing. How can I manage such an error ?
df = df_ori[[ 'FINAL', 'DUE', 'ID', 'NAME', 'BUSINESS 1', 'TAX 2', 'COUNT' ]] This works and df exists when all the variables in df_ori are there. But then I want to go further by managing a potential error if one variable is missing.
if df.empty: print("Field(s) mendatory missing") #doesn't work if in df_ori dataframe the field 'ID' is missing for instance. I cannot enter in this "IF"
No error but there is no dataframe df generated or "Field(s) mendatory missing" doesn't appear