I'm trying to extract variables from a data spreadsheet to form a boxplot which looks like this:
import matplotlib.pyplot as plt
import pandas as pd
pulserate = pd.read_csv("PulseNew.csv")
ran_yes = pulserate[pulserate["Ran"] == "yes"]
ran_no = pulserate[pulserate["Ran"] == "no"]
ry = ran_yes
rn = ran_no
ran_data = [ry, rn]
plt.boxplot(ran_data)
plt.show()
However, when I do this I end up receiving this error:
ValueError: X must have 2 or fewer dimensions
Upon seeing that, I tried inserting these lines instead:
pulserate = pd.read_csv("PulseNew.csv")
ran_yes = pulserate[pulserate["Ran"] == "yes"]
ran_no = pulserate[pulserate["Ran"] == "no"]
subset = pulserate[(pulserate["Ran"] == "yes") & (pulserate["Ran"] == "no")]
plt.boxplot(subset)
plt.show()
While this did not result in an error, all I got was an empty graph. For context, I'm a beginning Python programmer.
You must extract the column that you want to plot from each data frame and pass it as a 1D array:
Try this way and give me the result please.