相关疑难解决方法(0)

使用"符号"数字填充DataFrame

我有一个充满浮动(正面和负面)和一些NaN的DataFrame.我想用它的符号替换每个浮点数:

if it's NaN -> it remains Nan
if positive -> replace with 1
if negative -> replace with -1
if zero -> leave it as 0
Run Code Online (Sandbox Code Playgroud)

有什么建议可以进行大规模的替换?

先感谢您

python pandas

7
推荐指数
2
解决办法
9284
查看次数

标签 统计

pandas ×1

python ×1