I have a pandas dataframe that looks like this:
portion used
0 1 1.0
1 2 0.3
2 3 0.0
3 4 0.8
I'd like to create a new column based on the used
column, so that the df
looks like this:
portion used alert
0 1 1.0 Full
1 2 0.3 Partial
2 3 0.0 Empty
3 4 0.8 Partial
- Create a new
alert
column based on - If
used
is1.0
,alert
should beFull
. - If
used
is0.0
,alert
should beEmpty
. - Otherwise,
alert
should bePartial
.
What's the best way to do that?