Skip to main contentSkip to solution

Which of the following is correct way to create a pandas 'Series' from a list?

Solution

✅ Correct Option: 1

pd.Series() is the pandas constructor for a Series. Passing a list to it creates a one-dimensional labelled array, with a default index 0,1,2,…0, 1, 2, \dots added automatically.


Option 2: pd.DataFrame() also accepts a list, but it returns a two-dimensional DataFrame, not a Series.

Option 3: pandas has no ListSeries function.

Option 4: the order is reversed. Series belongs to the pandas module (pd.Series), so Series.pandas is invalid.

Remember: Series starts with a capital S, and pd.series() in lowercase gives an error.

Keyboard Shortcuts

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