mercredi 15 janvier 2020

trying to use def with a if statement inside

i'm trying to define a function where inside i could use a input statement for deciding what to do with my data, depending on the answer to a yes/no question. I just want to do this (explained in words): if the answer to my question (so the value of the list created, named task) is equal to 'no' just import a dataframe using pickle, else do other things (basically dealing with pandas dataframe).

This is my code:

def aggiorna_Veeva():
task = input("Vuoi Creare l'anagrafica Veeva da zero?(sì/no)")
if task=='no':
    print('importo il db')
    veeva_seg = pd.read_pickle( out + '\\veeva_seg.pkl')
else:
    print("creare il db da capo")
    veeva_seg = pd.read_csv('Segment_2019_LI.csv' , sep=';' , engine='python' ,  dtype = { 'Product Metrics: Last Modified Date' : np.datetime64 ,  'Account: Birthdate' : np.datetime64  }    )

My code seems to stop after this line: print('importo il db') (i just get the print result but not the following code line) , it seems that is not importing the dataframe, any suggestions?

Aucun commentaire:

Enregistrer un commentaire