Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Atom, Anaconda & Co.
#6
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
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
Reply


Messages In This Thread
Atom, Anaconda & Co. - by Jack_Sparrow - Apr-29-2018, 06:44 PM
RE: Atom, Anaconda & Co. - by Larz60+ - Apr-29-2018, 07:11 PM
RE: Atom, Anaconda & Co. - by killerrex - Apr-29-2018, 07:23 PM
RE: Atom, Anaconda & Co. - by snippsat - Apr-29-2018, 08:17 PM
RE: Atom, Anaconda & Co. - by Jack_Sparrow - Apr-30-2018, 07:55 AM
RE: Atom, Anaconda & Co. - by Jack_Sparrow - May-26-2018, 01:46 PM
RE: Atom, Anaconda & Co. - by killerrex - May-26-2018, 04:08 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020