C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Pandas DataFrame.count()The Pandas count() is defined as a method that is used to count the number of non-NA cells for each column or row. It is also suitable to work with the non-floating data. Syntax:DataFrame.count(axis=0, level=None, numeric_only=False) Parameters:
Returns:It returns the count of Series or DataFrame if the level is specified. Example 1: The below example demonstrates the working of the count(). import pandas as pd import numpy as np info = pd.DataFrame({"Person":["Parker", "Smith", "William", "John"], "Age": [27., 29, np.nan, 32] info.count() Output Person 5 Age 3 dtype: int64 Example 2: If we want to count for each of the row, we can use the axis parameter. The below code demonstrates the working of the axis parameter. import pandas as pd import numpy as np info = pd.DataFrame({"Person":["Parker", "Smith", "William", "John"], "Age": [27., 29, np.nan, 32] info.count(axis='columns') Output 0 2 1 2 2 1 3 2 dtype: int64
Next TopicDataFrame.cut()
|