I have a DataFrame named df
as
Order Number Status
1 1668 Undelivered
2 19771 Undelivered
3 100032108 Undelivered
4 2229 Delivered
5 00056 Undelivered
I would like to convert the Status
column to boolean (True
when Status is Delivered and False
when Status is Undelivered)
but if Status is neither 'Undelivered' neither 'Delivered' it should be considered as NotANumber
or something like that.
I would like to use a dict
d = {
'Delivered': True,
'Undelivered': False
}
so I could easily add other string which could be either considered as True
or False
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…