0
0
Data Analysis Pythondata~10 mins

head() and tail() in Data Analysis Python - Interactive Code Practice

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

Complete the code to show the first 3 rows of the DataFrame.

Data Analysis Python
df.[1](3)
Drag options to blanks, or click blank then click option'
Atail
Bhead
Cshow
Dfirst
Attempts:
3 left
💡 Hint
Common Mistakes
Using tail() instead of head() to get the first rows.
Using show() which is not a pandas DataFrame method.
Using first() which is not a pandas DataFrame method.
2fill in blank
medium

Complete the code to display the last 5 rows of the DataFrame.

Data Analysis Python
df.[1](5)
Drag options to blanks, or click blank then click option'
Atail
Bhead
Cend
Dlast
Attempts:
3 left
💡 Hint
Common Mistakes
Using head() instead of tail() to get the last rows.
Using end() or last() which are not pandas DataFrame methods.
3fill in blank
hard

Fix the error in the code to correctly show the first 4 rows of the DataFrame.

Data Analysis Python
df.[1](4)
Drag options to blanks, or click blank then click option'
Atail
Bfirst
Chead
Dshow
Attempts:
3 left
💡 Hint
Common Mistakes
Using tail() instead of head() to get the first rows.
Using show() which is not a pandas DataFrame method.
4fill in blank
hard

Fill both blanks to create a dictionary of word lengths for words longer than 3 characters.

Data Analysis Python
{word: [1] for word in words if len(word) [2] 3}
Drag options to blanks, or click blank then click option'
Alen(word)
B<=
C>
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself as the value instead of its length.
Using <= instead of > in the condition.
5fill in blank
hard

Fill all three blanks to create a dictionary with uppercase words as keys, their lengths as values, for words longer than 4 characters.

Data Analysis Python
{ [1]: [2] for word in words if len(word) [3] 4 }
Drag options to blanks, or click blank then click option'
Aword.upper()
Blen(word)
C>
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using the original word as key instead of uppercase.
Using <= instead of > in the condition.
Using the word itself as value instead of length.