Complete the code to create a box plot of the 'age' column using pandas.
import pandas as pd import matplotlib.pyplot as plt data = {'age': [23, 45, 31, 35, 22, 40, 29, 50]} df = pd.DataFrame(data) df.boxplot(column=[1]) plt.show()
The boxplot method requires the column name as a string, so we use 'age'.
Complete the code to create a box plot for the 'score' column with a grid.
import pandas as pd import matplotlib.pyplot as plt data = {'score': [88, 92, 79, 93, 85, 90, 87, 95]} df = pd.DataFrame(data) df.boxplot(column=[1], grid=True) plt.show()
The column name must be a string, so 'score' is correct.
Fix the error in the code to plot a box plot for the 'height' column.
import pandas as pd import matplotlib.pyplot as plt data = {'height': [160, 170, 165, 180, 175, 168, 172, 169]} df = pd.DataFrame(data) df.boxplot(column=[1]) plt.show()
The boxplot method needs the column name as a string, so 'height' is correct.
Fill both blanks to create a box plot for the 'weight' column and set the color to 'green'.
import pandas as pd import matplotlib.pyplot as plt data = {'weight': [70, 80, 75, 85, 90, 78, 82, 77]} df = pd.DataFrame(data) df.boxplot(column=[1], color=[2]) plt.show()
The column name must be a string 'weight', and the color string 'green' sets the box plot color.
Fill all three blanks to create a box plot for the 'salary' column, set the grid to True, and change the box color to 'red'.
import pandas as pd import matplotlib.pyplot as plt data = {'salary': [50000, 60000, 55000, 65000, 70000, 62000, 58000, 63000]} df = pd.DataFrame(data) df.boxplot(column=[1], grid=[2], color=[3]) plt.show()
The column name must be 'salary', grid set to True enables the grid, and color 'red' changes the box color.