Which of the following is a valid way to create a pandas series from a dictionary?
Which of the following is a valid way to create a pandas series from a dictionary?
Solution
✅ Correct Option: 3
pd.Series(data_dict) creates a Series from a dictionary. The dictionary keys become the index labels and the values become the data.
For example, pd.Series({'a': 1, 'b': 2}) gives a Series with index a, b and values 1, 2.
Option 1: pd.DataFrame(data_dict) builds a DataFrame (a 2-D table), not a Series.
Option 4: a Series is one-dimensional and has no column parameter, so this raises an error. The valid parameter is index.
Related questions:
2026: 26 May Shift 1
2026: 24 May Shift 1