Guided Project : Boxplot

I expected the minimum will be 2009 but I got 2010 as minimum
i did value counts for, tafe_resignations[“cease_date”].value_counts()
but where my 2009 go it should show as a minimum?
I’m thing because 2009 has a frequency of 4 but the others have more a lot more
2011.0 268
2012.0 235
2010.0 103
2013.0 85
2009.0 4

Screen Link:
image

My Code:

tafe_resignations.boxplot("cease_date").set_ylim(2008,2014)
plt.ticklabel_format(useOffset=False, axis='y')```

What I expected to happen:


What actually happened: 

Replace this line with the output/error


<!--Enter other details below: -->

Hi @hshf1992

The idea of boxplots is to show presence of all data points, even if they lie farther than the median. So having lowest/ less frequency may not be the reason why the boxplot doesn’t show 2009 as well.

Can you share with us the complete code, from the value count() to boxplot included. Has anything changed/ updated between these two code blocks?

hi @hshf1992

please follow Introducing guidelines for all technical questions in our Community to post your question so that the community can help you more efficiently.

Since I can’t access code from the screenshot, I tried with dummy code, the boxplot works fine with this sample. Please try it in your notebook and let us know if this also comes wrong.

Code:

s = pd.Series([2011, 2011, 2011, 2012, 2013, 2014, 2005, 2006, 2008, 2008, 2009, 2010, 2010, 2010 , 2011, 2011, 2012,
               2011, 2013, 2014, 2005, 2006, 2007, 2008, 2011, 2012, 2009, 2010, 2012] * 180)

df = pd.DataFrame({"s" : s})

df.boxplot("s").set_ylim(2000, 2016)
plt.ticklabel_format()
plt.show()

df["s"].value_counts().sort_index()

Output Plot:
image

You have executed some other code between the plot code and value_counts() as evident from output cells 53, & 55. 54 is missing or has been run twice. You can try the “Restart & Run all cells” option in your notebook, to have a sequential run of all cells.

In case this dummy code also doesn’t help then please share your notebook, to help find out what could be wrong here.

I tried it in my own Jupiter notebook worked fine, and I have tried the dummy code worked fine in the website, No problem.
‘’'tafe_resignations.boxplot(“cease_date”).set_ylim(2008,2014)
plt.ticklabel_format(useOffset=False, axis=‘y’)

tafe_resignations[“cease_date”].value_counts().sort_index()’’’

BoxPlot_1

1 Like

so is this now resolved or you still have some doubts?

No doubts, Problem Solved Thanks.

1 Like

Then please mark any relevant post as a solution as it keeps coming up for us as an open topic. Thanks.