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)
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.
Related questions:
2025: 13 May Shift 2
2026: 23 May Shift 2
2026: 23 May Shift 2