Skip to main contentSkip to solution

DataFrame can be created from:

(A) series

(B) lists

(C) numpy

(D) dictionary

Solution

✅ Correct Option: 3

A pandas DataFrame can be built from a Series, a list, a NumPy array or a dictionary, so all four (A), (B), (C) and (D) are correct.

SourceExample
Seriespd.DataFrame(s)
List (or list of lists)pd.DataFrame([[1, 2], [3, 4]])
NumPy arraypd.DataFrame(np.array([[1, 2], [3, 4]]))
Dictionarypd.DataFrame({'a': [1, 2], 'b': [3, 4]})

A dictionary of Series or lists is the most common method, with the keys becoming the column names.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question