0

I'm trying to count how many repeated data are there in each column in DataFrame.

This is a python 3.7.

I have tried df_.count(),but it is meant for axis. I expect the outcome to looks like:

    1   2
0   a   b 
1   a   b
2   b   c
3   c   a
4   a   c

column1.count(a)=3 column2.count(a)=1
column1.count(b)=1 column2.count(b)=2
column1.count(c)=1 column2.count(c)=2

and the count will be of further use.

Wei Lunss
  • 49
  • 4
  • 1
    Possible duplicate of [count the frequency that a value occurs in a dataframe column](https://stackoverflow.com/questions/22391433/count-the-frequency-that-a-value-occurs-in-a-dataframe-column) – Recessive Mar 28 '19 at 03:38

1 Answers1

0

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.value_counts.html

df.column_name.value_counts()
Ting
  • 3
  • 2