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)
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
(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.
Related questions:
2025: 3 June Shift 2
2026: 20 May Shift 1
2026: 23 May Shift 2
2026: 21 May Shift 1