I have the the following df
:
JavaScript
x
13
13
1
0 4.20
2
1 6.30
3
2 74.90
4
3 83.45
5
4 17.19
6
5 74.34
7
6 1717.73
8
7 139.05
9
8 753.36
10
9 4.54
11
10 60.07
12
Name: exports, dtype: float64
13
I would like take logs of the whole column, but when I try:
JavaScript
1
3
1
import numpy as np
2
lexports=np.log(df['exports'])
3
..I get the following error: AttributeError: 'int' object has no attribute 'log'
How can I fix this? I looked up other threads. They seem to explore causes, but don’t provide solutions.
Advertisement
Answer
This error means that you have used np as name for some other variable (of type integer)
You can run
JavaScript
1
2
1
del np
2
and
JavaScript
1
2
1
import numpy as np
2
again, and it will work