Completed

DataFrame — Creation

Class 12 · Informatics Practices Mon, 5 Oct 2026 9:00 PM 60s / question 15 questions · 15 marks

Questions From This Challenge

Q1mcq1 mark
Which of the following correctly creates a DataFrame from a dictionary whose values are Pandas Series objects?
pd.DataFrame({'Marks': pd.Series([80, 90], index=['A', 'B']), 'Age': pd.Series([16, 17], index=['A', 'B'])}) ✓
pd.DataFrame.fromSeries({'Marks': [80, 90], 'Age': [16, 17]})
pd.Series({'Marks': [80, 90], 'Age': [16, 17]})
pd.DataFrame.read_series({'Marks': [80, 90]})
Q2mcq1 mark
When a DataFrame is created from a dictionary of Series and the Series' index labels don't all match, what happens at positions where a label is missing from one of the Series?
Pandas inserts NaN for that column at that row ✓
Pandas raises a ValueError and refuses to create the DataFrame
Pandas drops that row entirely from the DataFrame
Pandas automatically fills the missing value with 0
Q3mcq1 mark
Which structure, when passed to pd.DataFrame(), has each element as a dictionary representing one row of the resulting table?
A list of dictionaries ✓
A dictionary of Series
A single dictionary of scalar values
A NumPy ndarray
Q4mcq1 mark
A DataFrame is created from the list of dictionaries [{'a': 1, 'b': 2}, {'a': 3, 'c': 4}]. What value appears in column 'c' for the first row (index 0)?
NaN ✓
0
4
An error is raised because the dicts have different keys
Q5mcq1 mark
Which Pandas function is used to read the contents of a CSV file directly into a DataFrame?
pd.read_csv() ✓
pd.load_csv()
pd.import_csv()
pd.open_csv()
Q6mcq1 mark
Which method is used to write/export a DataFrame's contents to a CSV file?
DataFrame.to_csv() ✓
DataFrame.write_csv()
DataFrame.export_csv()
DataFrame.save_csv()
Q7mcq1 mark
When a DataFrame is created from a dictionary of Series, what becomes the DataFrame's row index?
The union of the index labels of all the Series ✓
A fresh default RangeIndex regardless of the Series' indices
Only the index of the first Series in the dictionary
The dictionary's keys
Q8mcq1 mark
When a DataFrame is created from a dictionary of Series, what determines the DataFrame's column names?
The dictionary's keys ✓
The index labels of the Series
The data type of each Series
The order of the Series' values
Q9output1 mark
What is the output of the following code, which creates a DataFrame from a dictionary of two Series that share the same index?
import pandas as pd
d = {
    'Marks': pd.Series([80, 90, 70], index=['A', 'B', 'C']),
    'Age': pd.Series([16, 17, 16], index=['A', 'B', 'C'])
}
df = pd.DataFrame(d)
print(df)
Correct output: Marks Age A 80 16 B 90 17 C 70 16
Q10output1 mark
What is the output of the following code, where one of the two Series is missing an index label that the other has?
import pandas as pd
d = {
    'Marks': pd.Series([80, 90, 70], index=['A', 'B', 'C']),
    'Age': pd.Series([16, 17], index=['A', 'B'])
}
df = pd.DataFrame(d)
print(df)
Correct output: Marks Age A 80 16.0 B 90 17.0 C 70 NaN
Q11output1 mark
What is the output of the following code, which creates a DataFrame from a list of dictionaries that all share the same keys?
import pandas as pd
records = [{'Name': 'Ravi', 'Marks': 88}, {'Name': 'Sona', 'Marks': 92}]
df = pd.DataFrame(records)
print(df)
Correct output: Name Marks 0 Ravi 88 1 Sona 92
Q12output1 mark
What is the output of the following code, where the dictionaries in the list have different keys?
import pandas as pd
records = [{'Name': 'Ravi', 'Marks': 88}, {'Name': 'Sona', 'City': 'Delhi'}]
df = pd.DataFrame(records)
print(df)
Correct output: Name Marks City 0 Ravi 88.0 NaN 1 Sona NaN Delhi
Q13output1 mark
Assume a CSV file named students.csv exists in the working directory with the following contents: Name,Marks Amit,85 Bina,90 Charu,78 What is the output of the following code?
import pandas as pd
df = pd.read_csv('students.csv')
print(df)
Correct output: Name Marks 0 Amit 85 1 Bina 90 2 Charu 78
Q14output1 mark
Assume a CSV file named players.csv exists in the working directory with the following contents: Player,Score,Team Rahul,45,Blue Sana,62,Red Tom,38,Blue Uma,71,Red Vik,50,Blue What is the output of the following code?
import pandas as pd
df = pd.read_csv('players.csv')
print(df.head(2))
Correct output: Player Score Team 0 Rahul 45 Blue 1 Sana 62 Red
Q15output1 mark
What is the output of the following code, which creates a DataFrame from a dictionary of Series and then selects a single column?
import pandas as pd
d = {
    'Marks': pd.Series([80, 90, 70], index=['A', 'B', 'C']),
    'Age': pd.Series([16, 17, 16], index=['A', 'B', 'C'])
}
df = pd.DataFrame(d)
print(df['Age'])
Correct output: A 16 B 17 C 16 Name: Age, dtype: int64
Next Live Challenge
Network Types
Class 12 · Informatics Practices Fri, 23 Oct 2026, 9:00 PM
View Live Challenges →

← Back to Live Challenge History · Practice MCQs

CodeBuddy
Hi there! 👋 I'm CodeBuddy, your KV Coders assistant.

To help me give you the most accurate answers, please select your class and subject below, or just type your question!
Buddy is typing...