您需要传递布尔掩码和(两个)值列:
np.where(Full_Names_Test_2['MarketCap'] == 'n/a', 7)# should benp.where(Full_Names_Test_2['MarketCap'] == 'n/a', Full_Names_Test_2['MarketCap'], 7)
参见np.where
文档。
或者可替换地使用的
where系列方法:
Full_Names_Test_2['MarketCap'].where(Full_Names_Test_2['MarketCap'] == 'n/a', 7)



