0
0
Data Analysis Pythondata~10 mins

Series creation from lists and dicts 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 create a pandas Series from a list.

Data Analysis Python
import pandas as pd

numbers = [10, 20, 30, 40]
series = pd.Series([1])
print(series)
Drag options to blanks, or click blank then click option'
A[10, 20, 30, 40]
Bpd.Series
Cnumbers
D'numbers'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the list name as a string (with quotes).
Trying to pass the pd.Series function itself.
2fill in blank
medium

Complete the code to create a pandas Series from a dictionary.

Data Analysis Python
import pandas as pd

scores = {'Alice': 85, 'Bob': 90, 'Cara': 78}
series = pd.Series([1])
print(series)
Drag options to blanks, or click blank then click option'
Ascores
B'scores'
C['Alice', 'Bob', 'Cara']
D[85, 90, 78]
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the dictionary keys or values as a list instead of the dictionary itself.
Using quotes around the dictionary variable name.
3fill in blank
hard

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

Data Analysis Python
import pandas as pd

values = [100, 200, 300]
labels = ['a', 'b', 'c']
series = pd.Series(values, index=[1])
print(series)
Drag options to blanks, or click blank then click option'
Alabels
Bvalues
C'labels'
D[1, 2, 3]
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the data list as index.
Passing the variable name as a string.
4fill in blank
hard

Fill both blanks to create a Series from a dictionary and set a custom name for the Series.

Data Analysis Python
import pandas as pd

data = {'x': 1, 'y': 2, 'z': 3}
series = pd.Series([1], name=[2])
print(series)
Drag options to blanks, or click blank then click option'
Adata
B'MySeries'
C'data'
D['MySeries']
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the dictionary name as a string.
Passing the name as a list instead of a string.
5fill in blank
hard

Fill all three blanks to create a Series from a list, set custom index labels, and assign a name.

Data Analysis Python
import pandas as pd

values = [5, 10, 15]
labels = ['p', 'q', 'r']
series = pd.Series([1], index=[2], name=[3])
print(series)
Drag options to blanks, or click blank then click option'
Avalues
Blabels
C'Numbers'
D'values'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing variable names as strings.
Mixing up values and labels.
Not using quotes for the name.