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: 4 years ago
Posts: 31
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: 4 years ago
Posts: 52
 

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