How to iterate over a danfojs DataFrame

971 views Asked by At

Is it possible to iterate a danfojs DataFrame? Thought maybe could use the .iloc function with an index, but .iloc returns a DataFrame, not a Series.

1

There are 1 answers

0
Christopher Lee On

you have to select the field column like you would do in pandas.

 async function main(){
  let df = await dfd.readExcel(__dirname + "/FormKeff.xlsx")

  for (let i = 0; i < df.shape[0]; i++) {
    let person = {};
    person.name = df.iloc({rows: [i]})["Nome"].values[0];
    person.email = df.iloc({rows: [i]})["Email"].values[0];
    person.phone = df.iloc({rows: [i]})["Telefone"].values[0];
    person.created_at = df.iloc({rows: [i]})["Data"].values[0];
  }

}

main();