python where函数求助
import pandas as pdfrom pandas import Series, DataFrame
import numpy as np
a = pd.Series(,
index = ['f', 'e', 'd', 'c', 'b', 'a'])
b = pd.Series(,
index = ['a', 'b', 'c', 'd', 'e', 'f'])
a
Out:
f NaN
e 2.5
d 0.0
c 3.5
b 4.5
a NaN
dtype: float64
b
Out:
a 0.0
b NaN
c 2.0
d NaN
e NaN
f 5.0
dtype: float64
np.where(pd.isnull(a), b, a)
Out: array()
np.where(pd.isnull(b), b, a)
Out: array()
谁能解释一下np.where(pd.isnull(a), b, a) 和 np.where(pd.isnull(b), b, a)是什么意思啊?谢谢。
np.where(pd.isnull(a), b, a)--->a数据有缺失,输出b,否则输出a
搜索引擎搜索下
pandas的isnull()函数和numpy的where()函数就明白了
页:
[1]