Just call apply
and pass pd.Series.value_counts
:
In [212]:
df = pd.DataFrame(np.random.randint(0, 2, (10, 4)), columns=list('abcd'))
df.apply(pd.Series.value_counts)
Out[212]:
a b c d
0 4 6 4 3
1 6 4 6 7
More Related Contents:
- Replacing values represented by 'UN' with NaN
- What is the difference between NaN and None?
- Strings in a DataFrame, but dtype is object
- Performance of Pandas apply vs np.vectorize to create new column from existing columns
- What does axis in pandas mean?
- pandas select from Dataframe using startswith
- How to map numeric data into categories / bins in Pandas dataframe
- Coalesce values from 2 columns into a single column in a pandas dataframe
- Pandas: Subtracting two date columns and the result being an integer
- Convert timedelta64[ns] column to seconds in Python Pandas DataFrame
- Most efficient way to forward-fill NaN values in numpy array
- ‘DataFrame’ object has no attribute ‘sort’
- Pandas pd.Series.isin performance with set versus array
- Difference between data type ‘datetime64[ns]’ and ‘
- Missing data, insert rows in Pandas and fill with NAN
- python pandas flatten a dataframe to a list
- Precision lost while using read_csv in pandas
- Get week start date (Monday) from a date column in Python (pandas)?
- What is dtype(‘O’), in pandas?
- Compute *rolling* maximum drawdown of pandas Series
- pandas distinction between str and object types
- NumPy version of “Exponential weighted moving average”, equivalent to pandas.ewm().mean()
- Pandas: Difference between largest and smallest value within group
- Iterating pandas dataframe, checking values and creating some of them
- How to resample a dataframe with different functions applied to each column?
- Resample time series in pandas to a weekly interval
- Python Pandas: remove entries based on the number of occurrences
- Convert a column of timestamps into periods in pandas
- What is the Big O Complexity of Reversing the Order of Columns in Pandas DataFrame?
- How to use numpy to get the cumulative count by unique values in linear time?