English

Can you write a program to count the number of rows and columns in a DataFram?

Advertisements
Advertisements

Question

Can you write a program to count the number of rows and columns in a DataFram?

Code Writing
Advertisements

Solution

import pandas as pd
df = pd.DataFrame()
rows, columns = df.shape
print("Number of rows:", rows)
print("Number of columns:", columns)

Explanation:

shape returns the number of rows and columns in a DataFrame.

shaalaa.com
  Is there an error in this question or solution?
Chapter 2: Data Handling using Pandas - I - Intext Questions [Page 46]

APPEARS IN

NCERT Informatics Practices [English] Class 12
Chapter 2 Data Handling using Pandas - I
Intext Questions | Q 10 | Page 46
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×