0
0
Data Analysis Pythondata~10 mins

Series sorting 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 sort the Series in ascending order.

Data Analysis Python
import pandas as pd
s = pd.Series([3, 1, 2])
s_sorted = s.[1]()
Drag options to blanks, or click blank then click option'
Asorted
Bsort_index
Csort
Dsort_values
Attempts:
3 left
💡 Hint
Common Mistakes
Using sort_index() which sorts by index, not values.
Using sorted() which returns a list, not a Series.
2fill in blank
medium

Complete the code to sort the Series in descending order.

Data Analysis Python
import pandas as pd
s = pd.Series([3, 1, 2])
s_sorted_desc = s.sort_values([1]=False)
Drag options to blanks, or click blank then click option'
Areverse
Bdescending
Cascending
Dorder
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'descending' which is not a valid parameter.
Using 'reverse' which is not a parameter for sort_values.
3fill in blank
hard

Fix the error in the code to sort the Series by index.

Data Analysis Python
import pandas as pd
s = pd.Series([3, 1, 2], index=['b', 'a', 'c'])
s_sorted = s.[1]()
Drag options to blanks, or click blank then click option'
Asort_values
Bsort_index
Csort
Dsorted
Attempts:
3 left
💡 Hint
Common Mistakes
Using sort_values() which sorts by values, not index.
Using sorted() which returns a list, not a Series.
4fill in blank
hard

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

Data Analysis Python
words = ['apple', 'bat', 'carrot', 'dog']
lengths = {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 '<' instead of '>' which filters shorter words.
Using 'word' instead of 'len(word)' for the value.
5fill in blank
hard

Fill all three blanks to create a dictionary with uppercase keys and values greater than 1.

Data Analysis Python
data = {'a': 1, 'b': 2, 'c': 3}
result = { [1]: [2] for k, v in data.items() if v [3] 1 }
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
C>
Dk
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'k' instead of 'k.upper()' for keys.
Using '<' instead of '>' for filtering values.