Pandas DataFrame: count() function
DataFrame - count() function
The count() function is used to count non-NA cells for each column or row.
The values None, NaN, NaT, and optionally numpy.inf (depending on pandas.options.mode.use_inf_as_na) are considered NA.
Syntax:DataFrame.count(self, axis=0, level=None, numeric_only=False)
Parameters:
Name | Description | Type/Default Value | Required / Optional |
---|---|---|---|
axis | If 0 or ‘index’ counts are generated for each column. If 1 or ‘columns’ counts are generated for each row | {0 or ‘index’, 1 or ‘columns’} Default Value: 0 |
Required |
level | If the axis is a MultiIndex (hierarchical), count along a particular level, collapsing into a DataFrame. A str specifies the level name. | int or str | Optional |
numeric_only | Include only float, int or boolean data. | bool Default Value: False |
Returns: Series or DataFrame
For each column/row the number of non-NA/null entries. If level is specified returns a DataFrame.
Example:
Download the Pandas DataFrame Notebooks from here.
Previous: DataFrame - corr() function
Next: DataFrame - cov() function
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/pandas/dataframe/dataframe-count.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics