May-26-2018, 01:46 PM
I have follow table:
(6 cyl) 409
(4 cyl) 283
(8 cyl) 199
(5 cyl) 48
(12 cyl) 30
(10 cyl) 14
(2 cyl) 2
(16 cyl) 1
I extracted int from the (:, 0) so I have only 6 insist of 6 cyl.
This was my code
0 6
1 4
2 6
3 6
4 6
5 6
6 4
7 4
8 12
9 12
10 12
11 12
12 8
13 8
...
It seems to work. The problem is, when I check the value again with this statement
(6 cyl) 409
(4 cyl) 283
(8 cyl) 199
(5 cyl) 48
(12 cyl) 30
(10 cyl) 14
(2 cyl) 2
(16 cyl) 1
Why?
Actually, I expected this result:
6 409
4 283
8 199
5 48
12 30
10 14
2 2
16 1
(6 cyl) 409
(4 cyl) 283
(8 cyl) 199
(5 cyl) 48
(12 cyl) 30
(10 cyl) 14
(2 cyl) 2
(16 cyl) 1
I extracted int from the (:, 0) so I have only 6 insist of 6 cyl.
This was my code
df_08['cyl'].str.extract('(\d+)')And this is my result
0 6
1 4
2 6
3 6
4 6
5 6
6 4
7 4
8 12
9 12
10 12
11 12
12 8
13 8
...
It seems to work. The problem is, when I check the value again with this statement
df_08['cyl'].value_counts()I have the original result:
(6 cyl) 409
(4 cyl) 283
(8 cyl) 199
(5 cyl) 48
(12 cyl) 30
(10 cyl) 14
(2 cyl) 2
(16 cyl) 1
Why?
Actually, I expected this result:
6 409
4 283
8 199
5 48
12 30
10 14
2 2
16 1