dimanche 28 juin 2020

Iteration over columns problems on condition

I have a Dataset with several columns and a row named "Total" that stores values between 1 and 4. I want to iterate over each column, and based on the number stored in the row "Total", add a new row with "yes" or "No".
I also have a list "columns" for iteration. All data are float64

I´m new at python and i don't now if i'm doing the righ way because i´m getting all "yes".

for c in columns:
  if dados_por_periodo.at['Total',c] < 4:
    dados_por_periodo.loc['VA'] = "yes"
  else:
    dados_por_periodo.loc['VA'] = "no"

Thanks.

Aucun commentaire:

Enregistrer un commentaire