How do I get the ro...
 
Share:
Notifications
Clear all

How do I get the row count of a Pandas DataFrame?


Neha
 Neha
(@asha)
Member Admin
Joined: 1 year ago
Posts: 27
Topic starter  

I'm trying to get the number of rows of DataFrame (df) with Pandas. Can you please help?


Quote
Topic Tags
myTechMint
(@mytechmint)
Member Moderator
Joined: 1 year ago
Posts: 29
 

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
ReplyQuote