0

I am working with a CSV file with data. basically what i want is that if the value in temp_coil column is above 12, then make the respective value in column sensible_heat, latent_heat, total_capacity equals to zero.

here is my code so far

if df.temp_coil > 12 in df.columns:
     df.sensible_heat = 0
     df.latent_heat = 0
     df.total_capacity = 0
else:
     pass
Rookie 18
  • 31
  • 5

1 Answers1

0

You can use boolean indexing for this:

df['sensible_heat'][df.temp_coil > 12] = 0
df['latent_heat'][df.temp_coil > 12] = 0
df['total_capacity'][df.temp_coil > 12] = 0
Tim Roberts
  • 48,973
  • 4
  • 21
  • 30