Pandas Dataframe. Group By Value And Count
I have the following table: Days, Age, Sex 5, 39, F 4, 54, M 4, 26, M 5, 42, M 4, 29, M I want to count number of rows with F and M separately. The foll
Solution 1:
Just to add to Wen's answer. Alternatively, you can use value_counts
while selecting the column with df.Sex
.
df.Sex.value_counts()
M 4
F 1
Name: Sex, dtype: int64
Post a Comment for "Pandas Dataframe. Group By Value And Count"