方法一:只能单个元素替换

b.loc[b['text_a'].isnull(), 'label'] = 0

pandas替换某一列的空值为特定的值

 

方法二:一次性替换空值和非空值

b['label'] = b['text_a'].isna().map({True:0, False:1})

pandas替换某一列的空值为特定的值

相关文章:

  • 2022-12-23
  • 2023-01-16
  • 2022-01-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2023-03-12
猜你喜欢
  • 2022-12-23
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-23
相关资源
相似解决方案