python-3.xpandasdataframecounting

Count the number of entries in pandas dataframe


I would like to count and display the number of entries (not rows nor columns) in a pandas dataframe df is there any predefined function that do it? how could I display the number of my data file's entries ?!

import pandas as pd
df = pd.read_csv(r'D:/python_learning/pandas_test/my_data.csv')

df.info()

if(df.notnull):
    print("dataframe is not null")
    #print("the number of entries is: ... ")


Solution

  • I found this solution, and it's exactly what I wanted to display.

    print(len(df))