count_row = df.shape[0] # gives number of row count count_col = df.shape[1] # gives number of col count
Here is what the above code is Doing:
1. We’re using the shape method to get the dimensions of the DataFrame.
2. We’re using the shape attribute to get the number of rows and columns.
3. We’re using the shape index to get the number of rows and columns.
4. We’re using the shape tuple to get the number of rows and columns.