Python Forum
value_counts method question
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
value_counts method question
#1
I hope you are all having a good day. I am currently teaching myself Python through an online MOOC. I have a question about the following line of code:

test=list()
for num in sal['JobTitle']:
    if 'chief' in num.lower():
        sum1=True
    else:
        sum1=False
        test.append(sum1)
test2=pd.DataFrame(test)
test2['sum1'].value_counts()
I am trying to see the number of True and False responses through the value_counts method. However, I receive an error message stating "an integer is required." I am not looking for an entirely new way of obtaining this answer, rather, I am trying to figure out how to go about this method and obtain the solution. I really want to learn all the intricacies of Python.

Moderator: Please use code tags in the future, so code is easier to read.
- nilamo
Reply


Messages In This Thread
value_counts method question - by smw10c - Mar-22-2017, 07:23 PM
RE: value_counts method question - by nilamo - Mar-22-2017, 07:51 PM
RE: value_counts method question - by zivoni - Mar-22-2017, 10:15 PM
RE: value_counts method question - by smw10c - Mar-22-2017, 10:36 PM
RE: value_counts method question - by zivoni - Mar-22-2017, 10:59 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  pd.query method question PolskaYBZ 5 3,085 Jan-25-2019, 08:23 PM
Last Post: stullis
  PyCharm IDE: Method Not Showing Up Question: Bug or Feature? Oliver 2 3,719 Dec-04-2017, 11:54 AM
Last Post: Oliver
  Apply Method Question smw10c 4 5,539 Apr-08-2017, 12:47 PM
Last Post: smw10c

Forum Jump:

User Panel Messages

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