Complete the code to get the shape of the DataFrame.
import pandas as pd df = pd.DataFrame({'A': [1, 2], 'B': [3, 4]}) shape = df.[1]
The shape attribute gives the dimensions of the DataFrame as a tuple (rows, columns).
Complete the code to print the number of rows in the DataFrame.
import pandas as pd df = pd.DataFrame({'X': [5, 6, 7], 'Y': [8, 9, 10]}) rows = df.[1][0] print(rows)
The first element of df.shape is the number of rows.
Fix the error in the code to get the number of columns.
import pandas as pd df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]}) cols = df.shape[1]1 print(cols)
To access the second element of the tuple df.shape, use square brackets [1].
Fill both blanks to create a dictionary with words as keys and their lengths as values, only for words longer than 3 letters.
words = ['apple', 'bat', 'carrot', 'dog'] lengths = {word: [1] for word in words if len(word) [2] 3}
Use len(word) to get length and filter words with length greater than 3 using >.
Fill all three blanks to create a dictionary with uppercase words as keys and their lengths as values, only for words longer than 3 letters.
words = ['apple', 'bat', 'carrot', 'dog'] result = { [1]: [2] for word in words if len(word) [3] 3 }
Use word.upper() as key, len(word) as value, and filter words with length greater than 3 using >.