Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between pd.df.plot.box() and pd.df.boxplot()

Why pandas has two funcitons for Boxplot : pandas.DataFrame.plot.box() and pandas.DataFrame.boxplot() ?

df = pd.DataFrame(np.random.rand(10, 5), columns=['A', 'B', 'C', 'D', 'E'])
df.plot.box()

enter image description here

df.boxplot()

enter image description here

like image 474
Math Avatar asked Dec 28 '18 22:12

Math


1 Answers

Both return a 'matplotlib.axes._subplots.AxesSubplot' object. Obviously, they are calling upon different parts of the pandas library to execute.

One of the consequences of this is that the pandas.DataFrame.plot.box() method uses the FramePlotMethods class where "grid = None" and pandas.DataFrame.boxplot() has "grid = True" by default. You'll notice this in the background lines in your two charts.

Additionally, .boxplot() can't be used on a Series, whereas .plot's can.

like image 90
psychopg2 Avatar answered Oct 17 '22 06:10

psychopg2