如何转换为以2为底的对数?

问题描述

如何将以下代码转换为以2为底的日志?

df["col1"] = df["Target"].map(lambda i: np.log(i) if i > 0 else 0)

解决方法

我认为您只想使用np.log2而不是np.log