Skip to main contentSkip to solution

Arrange the following steps to create the series with a NumPy Array:

A. import pandas as pd

B. series3 = pd.Series(array1)

C. array1 = np.array([1,2,3,4])

D. print(series3)

Solution

✅ Correct Option: 2

A, C, B, D is the only order where each name is defined before it is used.

A. import pandas as pd comes first, so that pd is available.

C. array1 = np.array([1,2,3,4]) creates the NumPy array.

B. series3 = pd.Series(array1) converts the array into a Series.

D. print(series3) displays the Series.


Options 1 and 4: pd.Series(...) is called in step B before import pandas as pd in step A, which gives a NameError.

Option 3: it starts with step B, which uses array1 and pd before either exists.

Note: np also needs import numpy as np, which is not listed among these steps.

Keyboard Shortcuts

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