0
0
Data Analysis Pythondata~10 mins

Why Series is the 1D data structure in Data Analysis Python - Test Your Understanding

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

data = [10, 20, 30]
series = pd.[1](data)
print(series)
Drag options to blanks, or click blank then click option'
ASeries
Blist
Carray
DDataFrame
Attempts:
3 left
💡 Hint
Common Mistakes
Using DataFrame instead of Series
Trying to use list or array which are not pandas objects
2fill in blank
medium

Complete the code to access the first element of a Series.

Data Analysis Python
import pandas as pd

s = pd.Series([5, 10, 15])
first_element = s.[1][0]
print(first_element)
Drag options to blanks, or click blank then click option'
Aloc
Bindex
Ciloc
Dvalues
Attempts:
3 left
💡 Hint
Common Mistakes
Using loc which accesses by label
Using index which returns index labels, not values
3fill in blank
hard

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

Data Analysis Python
import pandas as pd

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

Fill both blanks to create a Series and filter values greater than 15.

Data Analysis Python
import pandas as pd

s = pd.Series([10, 20, 30, 5])
filtered = s[s [1] [2]]
print(filtered)
Drag options to blanks, or click blank then click option'
A>
B15
C<
D20
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>'
Using wrong number for comparison
5fill in blank
hard

Fill all three blanks to create a dictionary from a Series with values greater than 10 and keys as uppercase labels.

Data Analysis Python
import pandas as pd

s = pd.Series([5, 15, 25], index=['x', 'y', 'z'])
result = [1]([2].upper(): [3] for [2], [3] in s.items() if [3] > 10)
print(result)
Drag options to blanks, or click blank then click option'
Adict
Bk
Cv
Dk.upper()
Attempts:
3 left
💡 Hint
Common Mistakes
Not converting keys to uppercase
Using wrong variable names in comprehension