Topic starter 13/07/2021 11:18 am
I'm trying to get the number of rows of DataFrame (df) with Pandas. Can you please help?
13/07/2021 3:11 pm
For a DataFrame df
, one can use any of the following:
- len(df.index)
- df.shape[0]
count_row = df.shape[0] # Gives number of rows count_col = df.shape[1] # Gives number of columns
- df[df.columns[0]].count() (slowest, but avoids counting NaN values in the first column)
Neha liked