Skip to main contentSkip to solution

Arrange the following code for plotting the Boxplot:

(A) data= pd.read_csv('exam.csv')

(B) df.plot(kind='box',title='exam')

(C) import pandas as pd; import matplotlib.pyplot as plt

(D) df= pd.DataFrame(data)

Solution

✅ Correct Option: 4

(C) import pandas as pd; import matplotlib.pyplot as plt comes first, because the libraries must be loaded before they are used.

(A) data= pd.read_csv('exam.csv') comes second, to read the file into data.

(D) df= pd.DataFrame(data) comes third, to build the DataFrame from data.

(B) df.plot(kind='box',title='exam') comes last, to draw the boxplot from df.


Option 1: (D) uses data before (A) has created it.

Options 2 and 3: (B) plots df before the data is read or the DataFrame is built.

Keyboard Shortcuts

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