How do you count the number of rows in a data frame?

How do you count the number of rows in a data frame?
Answer
Use pandas.DataFrame.index to count the number of rows
  1. df = pd. DataFrame({“Letters”: [“a”, “b”, “c”], “Numbers”: [1, 2, 3]})
  2. print(df)
  3. index = df. index.
  4. number_of_rows = len(index) find length of index.
  5. print(number_of_rows)
 

Tìm kiếm

Back
Top