0
0
Data Analysis Pythondata~10 mins

DataFrame structure (index, columns, values) 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 get the row labels of the DataFrame.

Data Analysis Python
row_labels = df.[1]
Drag options to blanks, or click blank then click option'
Avalues
Bindex
Ccolumns
Dshape
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'columns' instead of 'index' to get row labels.
Trying to use 'values' which gives the data, not labels.
2fill in blank
medium

Complete the code to get the column labels of the DataFrame.

Data Analysis Python
column_labels = df.[1]
Drag options to blanks, or click blank then click option'
Akeys
Bindex
Cvalues
Dcolumns
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'index' which is for rows, not columns.
Using 'values' which gives the data, not labels.
3fill in blank
hard

Fix the error in the code to get the data values of the DataFrame.

Data Analysis Python
data = df.[1]()
Drag options to blanks, or click blank then click option'
Ato_numpy
Bget_values
Cdata
Dvalues
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'values()' as if it were a method (it's an attribute).
Using deprecated 'get_values()' method.
4fill in blank
hard

Fill both blanks to create a DataFrame with specified index and columns.

Data Analysis Python
df = pd.DataFrame(data, index=[1], columns=[2])
Drag options to blanks, or click blank then click option'
A['row1', 'row2']
B['col1', 'col2']
C['a', 'b']
D['x', 'y']
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping index and columns values.
Using labels that don't match data dimensions.
5fill in blank
hard

Fill all three blanks to create a DataFrame from a dictionary with correct index and columns.

Data Analysis Python
df = pd.DataFrame([1], index=[2], columns=[3])
Drag options to blanks, or click blank then click option'
A{'A': [1, 2], 'B': [3, 4]}
B['row1', 'row2']
C['A', 'B']
D{'X': [5, 6], 'Y': [7, 8]}
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up data dictionary and labels.
Using column labels that don't match dictionary keys.