0
0
Pandasdata~10 mins

Creating Series from list and dictionary in Pandas - Interactive Practice

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

Complete the code to create a pandas Series from a list of numbers.

Pandas
import pandas as pd
numbers = [10, 20, 30]
series = pd.Series([1])
print(series)
Drag options to blanks, or click blank then click option'
Anumbers
Bdict
Cpd.DataFrame
Dlist
Attempts:
3 left
💡 Hint
Common Mistakes
Passing 'dict' or 'pd.DataFrame' instead of the list variable.
Passing the string 'list' instead of the variable.
2fill in blank
medium

Complete the code to create a pandas Series from a dictionary with custom index labels.

Pandas
import pandas as pd
scores = {'Alice': 85, 'Bob': 90, 'Carol': 78}
series = pd.Series([1], index=['Bob', 'Carol', 'Alice'])
print(series)
Drag options to blanks, or click blank then click option'
A['Alice', 'Bob', 'Carol']
Blist(scores.values())
C{'Bob': 90, 'Carol': 78, 'Alice': 85}
Dscores
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a list of keys instead of the dictionary.
Passing only the values without keys.
3fill in blank
hard

Fix the error in the code to create a Series from a list with custom index labels.

Pandas
import pandas as pd
values = [100, 200, 300]
series = pd.Series(values, index=[1])
print(series)
Drag options to blanks, or click blank then click option'
A['a', 'b']
B['x', 'y', 'z']
C['1', '2', '3', '4']
D['one', 'two']
Attempts:
3 left
💡 Hint
Common Mistakes
Using an index list with fewer or more labels than data items.
Using numeric strings that don't match data length.
4fill in blank
hard

Fill both blanks to create a Series from a dictionary and select values greater than 80.

Pandas
import pandas as pd
grades = {'Math': 75, 'Science': 88, 'English': 92}
series = pd.Series([1])
high_scores = series[series [2] 80]
print(high_scores)
Drag options to blanks, or click blank then click option'
Agrades
B>
C<
D[80]
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong comparison operator like '<' or '[80]'.
Passing the wrong data type to pd.Series.
5fill in blank
hard

Fill all three blanks to create a Series from a list, assign custom index, and filter values less than 50.

Pandas
import pandas as pd
values = [45, 60, 30, 80]
series = pd.Series([1], index=[2])
filtered = series[series [3] 50]
print(filtered)
Drag options to blanks, or click blank then click option'
Avalues
B['a', 'b', 'c', 'd']
C<
D['x', 'y', 'z']
Attempts:
3 left
💡 Hint
Common Mistakes
Using an index list with wrong length.
Using wrong comparison operator like '>' instead of '<'.