vendredi 22 mai 2020

Why I am not getting string correct label to python dataframe with timeseries?

I want to label each value in data frame, if there is zero then label with GND and not zero then name Dry but I am receiving only GND label to whole data frame.

result:

Timestamp   Dryer_power Label

2012-06-01 00:33:37 0.0 GND,
2012-06-01 00:33:38 0.0 GND,
2012-06-01 00:33:39 2.1906  GND,
2012-06-01 00:33:40 0.0 GND,
2012-06-01 00:33:41 0.0 GND,
2012-06-01 00:33:42 0.0 GND,
2012-06-01 00:33:43 0.0 GND,
2012-06-01 00:33:44 0.0 GND,
2012-06-01 00:33:45 0.0 GND,
2012-06-01 00:33:46 0.0 GND,
2012-06-01 00:33:47 2.1906  GND,
2012-06-01 00:33:48 0.0 GND,
2012-06-01 00:33:49 0.0 GND,

for i in df['Dryer_power'].iloc[:]:
    if(i == float(0)):
         df['Label'] = 'GND,'
    else:
         df['Label'] = 'Dry, '

Aucun commentaire:

Enregistrer un commentaire