参考链接: Python中的numpy.place
注意: df1.where(cond,df2) 等价于 np.where(cond, df1, df2)
1. pandas.DataFrame.where...参数: cond 查找条件 other cond为False时要替换的值 inplace 是否在原数据上操作
>>> import numpy as np
>>> import pandas as pd...>>> import numpy as np
>>> a = np.arange(10)
>>> a
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> np.where...必须和 condition 相同(可以采用 broadcast,广播机制) ①如果参数有condition,x和y,它们三个参数的shape是相同的。...(x>5) # ndarray 数组分别表示对应的 行和列
(array([2, 2, 2], dtype=int64), array([0, 1, 2], dtype=int64))
https