mercredi 27 janvier 2021

How to send variable created in if to elif in python?

I am trying to access a data frame created in an if condition from an elif but getting an error. How do I pass a Data Frame created in if to elif?

input:
if df[col].dtype == 'int':
   (some operations)
   df1 = df
elif df[col].dtype == 'obj':
    print(df1.isnull())

NameError: name 'df1' is not defined

Aucun commentaire:

Enregistrer un commentaire