gpt4 book ai didi

python - python 相当于 R 的 NA 是什么?

转载 作者:IT老高 更新时间:2023-10-28 21:01:56 26 4
gpt4 key购买 nike

python 相当于 R 的 NA 是什么?

更具体地说:R 有 NaN、NA、NULL、Inf 和 -Inf。 NA 通常在缺少数据时使用。 python的等价物是什么?

numpy 和 pandas 等库如何处理缺失值?

scikit-learn 如何处理缺失值?

python 2.7 和 python 3 有区别吗?

最佳答案

numpy 中的

nan 处理得很好,有很多功能:

>>> import numpy as np
>>> a = [1, np.nan, 2, 3]
>>> np.nanmean(a)
2.0
>>> np.nansum(a)
6.0
>>> np.isnan(a)
array([False, True, False, False], dtype=bool)

关于python - python 相当于 R 的 NA 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28654325/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com