Adding two Series with NaNs

前端 未结 3 1058
孤街浪徒
孤街浪徒 2020-11-29 10:22

I\'m working through the \"Python For Data Analysis\" and I don\'t understand a particular functionality. Adding two pandas series objects will automatically align the index

3条回答
  •  天命终不由人
    2020-11-29 10:39

    The default approach is to assume that any computation involving NaN gives NaN as the result. Anything plus NaN is NaN, anything divided by NaN is NaN, etc. If you want to fill the NaN with some value, you have to do that explicitly (as Dan Allan showed in his answer).

提交回复
热议问题