Reputation: 2080
How to convert log2 transformed values back to normal scale in python Any suggestions would be great
Upvotes: 1
Views: 2158
Reputation: 101
log2(x)
is the inverse of 2**x
(2 to the power of x). If you have a column of data that has been transformed by log2(x)
, all you have to do is perform the inverse operation:
df['colname'] = [2**i for i in df['colname']]
As suggested in the comment below, it would be more efficient to do:
df['colname'] = df['colname'].rpow(2)
rpow
is a pandas Series method that is built in to the pandas package. The first argument is the base you'd like to take powers to. You can also use a fill_value
argument, which is nice because you can tell it what to do if the result is NaN
Upvotes: 2