Полагаю, вам нужно numpy.where
в целом, но для log
возможно добавить параметр where
в numpy.log
.
Эта функция возвращаетмассив numy 1d, поэтому для нового Series
необходим конструктор:
s = pd.Series([0,1,5])
s1 = pd.Series(np.log(s,where=s>0), index=s.index)
или:
s1 = pd.Series(np.where(s==0,0,np.log(s)), index=s.index)
print (s1)
0 0.000000
1 0.000000
2 1.609438
dtype: float64