dimanche 25 mars 2018

IF sentence in a FOR loop throughout a dataframe: performance improvement

I'm using an if statement inside a for loop throughout a pandas datafame, but it is taking too long to process. Is there a way to do this without the for loop?

for i in data.index:
    if data['qt_CNAE'][i] > 20:
        data['CNAEuse'][i]=data['CNAE'][i]
        data['CNAEuse_Cres'][i]=data['Crescimento_CNAE'][i]

Aucun commentaire:

Enregistrer un commentaire