Complete the code to create a DataFrame from the list of dictionaries named data.
import pandas as pd data = [{'name': 'Alice', 'age': 25}, {'name': 'Bob', 'age': 30}] df = pd.[1](data) print(df)
The DataFrame constructor creates a DataFrame from a list of dictionaries.
Complete the code to print the first two rows of the DataFrame df.
import pandas as pd data = [{'name': 'Alice', 'age': 25}, {'name': 'Bob', 'age': 30}, {'name': 'Cara', 'age': 22}] df = pd.DataFrame(data) print(df.[1](2))
The head() method shows the first rows of a DataFrame. Passing 2 shows the first two rows.
Fix the error in the code to create a DataFrame from data.
import pandas as pd data = [{'name': 'Alice', 'age': 25}, {'name': 'Bob', 'age': 30}] df = pd.DataFrame[1]data print(df)
The DataFrame constructor requires parentheses around the data argument.
Fill both blanks to create a DataFrame from data and select only the 'name' column.
import pandas as pd data = [{'name': 'Alice', 'age': 25}, {'name': 'Bob', 'age': 30}] df = pd.[1](data) names = df[[2]] print(names)
Use DataFrame to create the table and select the 'name' column by its string key.
Fill all three blanks to create a DataFrame from data, filter rows where age is greater than 25, and print the result.
import pandas as pd data = [{'name': 'Alice', 'age': 25}, {'name': 'Bob', 'age': 30}, {'name': 'Cara', 'age': 22}] df = pd.[1](data) filtered = df[df[[2]] [3] 25] print(filtered)
Create the DataFrame, then filter rows where the 'age' column is greater than 25 using the > operator.