0
0
Pandasdata~10 mins

Why Pandas for data analysis - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the pandas library with the common alias.

Pandas
import [1] as pd
Drag options to blanks, or click blank then click option'
Apandas
Bseaborn
Cmatplotlib
Dnumpy
Attempts:
3 left
💡 Hint
Common Mistakes
Importing numpy instead of pandas
Using a wrong alias like 'np' for pandas
2fill in blank
medium

Complete the code to create a DataFrame from a dictionary.

Pandas
data = {'Name': ['Alice', 'Bob'], 'Age': [25, 30]}
df = pd.[1](data)
Drag options to blanks, or click blank then click option'
ADataFrame
BSeries
Carray
Dlist
Attempts:
3 left
💡 Hint
Common Mistakes
Using Series instead of DataFrame
Trying to create a list or array instead
3fill in blank
hard

Fix the error in the code to display the first 3 rows of the DataFrame.

Pandas
df.[1](3)
Drag options to blanks, or click blank then click option'
Ashow
Bprint
Ctail
Dhead
Attempts:
3 left
💡 Hint
Common Mistakes
Using tail() instead of head()
Trying to use print() as a method on DataFrame
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps words to their lengths only if length is greater than 3.

Pandas
{word: [1] for word in words if [2] > 3}
Drag options to blanks, or click blank then click option'
Alen(word)
Bword
Clen(words)
Dword.length
Attempts:
3 left
💡 Hint
Common Mistakes
Using length of the whole list instead of each word
Using an attribute 'length' which does not exist for strings
5fill in blank
hard

Fill all three blanks to create a dictionary from data items where values are positive.

Pandas
result = [1]: [2] for [1] , [2] in data.items() if [2] [3] 0}
Drag options to blanks, or click blank then click option'
Ak
Bv
C>
Dk.upper()
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same variable name for key and value
Using a wrong comparison operator