Im quite new to programming (in python) and I would like to create a new variable that is the logarithm of a column (from an imported excel file). I have tried different solutions from this site, but I keep getting an error. My latest error is AttributeError: 'str' object has no attribute 'log'.
I have already dropped all the values that are not "numbers', but I still don't know how to convert the values from strings to integers (if this is the case, because 'int(neighborhood)' doesn't work).
This is the code I have now:
import pandas as pd
import numpy as np
df=pd.read_excel("kwb-2016_del_col_del_row.xls")
df = df[df.m_woz != "."] # drop rows with values "."
neighborhood=df[df.recs=="Neighborhood"]
neighborhood=neighborhood["m_woz"]
print(neighborhood)
np.log(neighborhood)
and this is the error I'm getting:
AttributeError Traceback (most recent call last)
<ipython-input-66-46698de51811> in <module>()
12 print(neighborhood)
13
---> 14 np.log(neighborhood)
AttributeError: 'str' object has no attribute 'log'
Could someone help me please?