I want to take the logarithm of every value in a pandas dataframe. I have tried this but it does not work:
#Reading data from excel and rounding values on 2 decimal places
import math
import pandas as pd
data = pd.read_excel("DataSet.xls").round(2)
log_data= math.log10(data)
It gives me this error:
TypeError: must be real number, not DataFrame
Do you have any idea what to do?
pandas.DataFrame.head() In Python's Pandas module, the Dataframe class provides a head() function to fetch top rows from a Dataframe i.e. It returns the first n rows from a dataframe.
Use iloc[] to select last N columns of pandas dataframe. Use [] to select last N columns of pandas dataframe. Use tail() to select last N columns of pandas dataframe.
Use the numpy version, not math
import numpy as np
np.log10(df)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With