jeudi 10 septembre 2020

using pandas Generate csv file using if condition

I have columns like start_time, end_time and time_taken in minutes. I want to generate a csv file with full data only if time_taken equals to 10 minutes.

My current code is:

if ( df['time_taken']) == 10:
  df.to_csv(r'result.csv')

It is giving error like:

The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().

Aucun commentaire:

Enregistrer un commentaire