我需要根据NaN值将列更改为True或False。
这是df。
input Pets {
pet: String!,
food: [Brands!]!
}
input Brands {
brand: String!,
types: String! | FoodOptions // here is where I'm getting stuck. i know `or` isn't possible but don't know of a different solution.
}
input FoodOptions {
type1: String!,
type2: String
}
将成为
missing
0 NaN
1 b
2 NaN
4 y
5 NaN
是的,我可以做一个循环,但是有一种简单的方法可以在一行代码中完成。
谢谢。
答案 0 :(得分:2)
你可以做
df['missing'].notna() # or notnull()
答案 1 :(得分:1)
您需要使用应用于同一列的二进制值来覆盖列值,这可以通过notna()实现
df['missing'] = df['missing'].notna()