Printing out dimensions of a DataFrame

Report a typo

Write a function print_dim that takes a DataFrame object and prints out the text 'This DataFrame contains X rows and Y columns', where X and Y are the number of rows and columns in the DataFrame.

For example, for a DataFrame like this

+--------+---------------+-------------------+
|        | Title         | Author            |
|--------+---------------+-------------------|
|   Year |               |                   |
|--------+---------------+-------------------|
|   1877 | Anna Karenina | Leo Tolstoy       |
|   1815 | Emma          | Jane Austen       |
|   1860 | Little Women  | Louisa May Alcott |
|   1847 | Jane Eyre     | Charlotte Brontë  |
+--------+---------------+-------------------+

the output should be: This DataFrame contains 4 rows and 2 columns(note that 'Year' is an index here).

Write a program in Python 3
import pandas as pd


def print_dim(df):
pass
___

Create a free account to access the full topic