samedi 20 avril 2019

new column base on existing column values

Trying to create a new values Chill or Frozen base on existing column "Temp" values.

The Temp contains values like:

-18.00C
-20.00C
+10.00C
+19.00C
Nan
DRY

How can implement it using Pandas

df = pd.DataFrame({'Temp': ['-18.00C', '+10.00c', 'NaN', 'DRY']})

If the Temp is < 0.0C, it will fall under Frozen
If the Temp is > 0.0C, it will fall under Chill
If the Temp is "Nan" or "DRY", it will fall under NA

Expected Results:

Temp_Category
Frozen
Chill
NA
NA

Aucun commentaire:

Enregistrer un commentaire