import pandas as pd
data = {
"subjects": ["Math", "Physics", "Chemistry", "English", "Hindi"],
"scores": [90, 80, 87, 80, 70]
}
df = pd.DataFrame(data)
# Get rows and columns count
result = df.shape
print("Rows: ", result[0])
print("Columns: ", result[1])
Output
Rows: 5
Columns: 2
DataFrame.shape returns a tuple that contains two integer type values. The first value is the count of Rows in the DataFrame and the second value is the total number of Columns in the DataFrame.
0 Comments