Recall & Review
beginner
What is a DataFrame in pandas?
A DataFrame is a table-like data structure in pandas that holds data in rows and columns, similar to a spreadsheet or SQL table.
Click to reveal answer
beginner
How do you create a DataFrame from a NumPy array?
Use
pd.DataFrame() and pass the NumPy array as the first argument. You can also add column names using the columns parameter.Click to reveal answer
beginner
Why might you want to create a DataFrame from a NumPy array?
Because DataFrames provide easy ways to label data, handle missing values, and perform data analysis with many built-in functions.
Click to reveal answer
beginner
What parameter do you use to name columns when creating a DataFrame from a NumPy array?
You use the
columns parameter and provide a list of column names.Click to reveal answer
beginner
If you have a NumPy array with shape (3, 2), how many rows and columns will the DataFrame have?
The DataFrame will have 3 rows and 2 columns, matching the shape of the NumPy array.
Click to reveal answer
Which function creates a DataFrame from a NumPy array?
✗ Incorrect
The correct function to create a DataFrame from a NumPy array is pd.DataFrame().
What does the 'columns' parameter do when creating a DataFrame from a NumPy array?
✗ Incorrect
The 'columns' parameter sets the column names of the DataFrame.
If your NumPy array has shape (5, 4), what will be the shape of the DataFrame created from it?
✗ Incorrect
The DataFrame shape matches the NumPy array shape: 5 rows and 4 columns.
Which library do you import to create a DataFrame from a NumPy array?
✗ Incorrect
You use pandas to create DataFrames.
What type of data structure is a pandas DataFrame?
✗ Incorrect
A DataFrame is a two-dimensional table with rows and columns.
Explain how to create a pandas DataFrame from a NumPy array and how to add column names.
Think about the function and the parameter for naming columns.
You got /4 concepts.
Describe why converting a NumPy array to a DataFrame can be useful in data analysis.
Consider the advantages of DataFrames over raw arrays.
You got /4 concepts.