-2

I am a newbie in data analysis stuff. I am trying to analyse a dataset using python. enter image description here

  1. I want to count no. of 1s in survived column
  2. No. of male , female in Sex column

PassengerId Survived Pclass Sex
0 1 0 3 male 1 2 1 1 female 2 3 1 3 male 3 4 1 1 female 4 5 0 3 male

I tried groupby() but its giving error.

In[88] titanic_data.groupby('Survived') Out[88] <pandas.core.groupby.DataFrameGroupBy object at 0x000000000BFFE588>

Please suggest solution

3
  • 2
    Can you show your efforts, also the norm is to provide raw data rather than an image of your data. Commented Jul 28, 2016 at 7:44
  • Thanks for suggesting me to paste raw data. I have posted it. Commented Jul 28, 2016 at 7:56
  • To clarify, it isn't giving an error. It is printing an object reference rather than a human-readable format for the table (because of the grouping). Edit submitted. Commented Aug 16, 2018 at 14:20

1 Answer 1

5

use value_counts:

df['Survived'].value_counts()
df['Sex'].value_counts()
Sign up to request clarification or add additional context in comments.

3 Comments

1 problem per question, incrementing your requirements is poor form, SO is not a forum
@EdChum thanks for your suggestion
This counts total number of male and female but how about number of females in pclass1 and number of males in pclass2 etc?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.