Skip to main contentSkip to solution

Arrange the steps of creating a DataFrame from the numpy array:

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

B. import numpy as np

import pandas as pd

C. dframe= pd.DataFrame(array1)

D. print (dframe)

Solution

✅ Correct Option: 2

The libraries must be imported first, the array must exist before it is converted, and the DataFrame must exist before it is printed.

B. import numpy as np and import pandas as pd

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

C. dframe= pd.DataFrame(array1)

D. print (dframe)


Option 1: A uses np before numpy is imported, which gives a NameError.

Option 3: D prints dframe before C creates it.

Keyboard Shortcuts

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