A DataFrame can be created from:-
(A) Dictionary of lists
(B) List of dictionaries
(C) Numpy array
(D) Series
A DataFrame can be created from:-
(A) Dictionary of lists
(B) List of dictionaries
(C) Numpy array
(D) Series
Solution
✅ Correct Option: 3
All four can be passed to pd.DataFrame():
(A) Dictionary of lists: keys become column names and each list becomes a column.
(B) List of dictionaries: each dictionary becomes a row, and keys become column names.
(C) Numpy array: a 2D array becomes rows and columns.
(D) Series: pd.DataFrame(s) gives a one-column DataFrame, and a dictionary of Series gives several columns.
Option 2: a common mistake is to think a 1D Series cannot form a DataFrame, but it can, as a single column.
Related questions:
2025: 30 May Shift 2
2026: 13 May Shift 2
2025: 3 June Shift 2