-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

Rahul Saxena
  • 422
  • 1
  • 9
  • 22
  • 2
    Can you show your efforts, also the norm is to provide raw data rather than an image of your data. – EdChum Jul 28 '16 at 07:44
  • Thanks for suggesting me to paste raw data. I have posted it. – Rahul Saxena Jul 28 '16 at 07: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. – IBBoard Aug 16 '18 at 14:20

1 Answers1

5

use value_counts:

df['Survived'].value_counts()
df['Sex'].value_counts()
shivsn
  • 7,680
  • 1
  • 26
  • 33