小编K.M*_*.M.的帖子

Python: 0 if Null, and 1 if not

I'm trying to create a column in my data set such that any null values can be set to 0, and non-null values are set to 1. For starters, my column of data called '9Age', roughly speaking, looks like this:

NaN
6
5
NaN
2
NaN
3
5
4
Run Code Online (Sandbox Code Playgroud)

Setting null values to 0 can be as easy as doing this:

Age0 = df['9Age'].fillna(0)
Run Code Online (Sandbox Code Playgroud)

However, here's the rest of my attempt: Deciding whether a value is null or not was …

python null pandas

4
推荐指数
2
解决办法
4937
查看次数

标签 统计

null ×1

pandas ×1

python ×1