I have a small question about the .plot()
method in pandas.
So, let us say you have a dateframe saved into the variable: df
. Let us say you wanted to make a bar chart about the data in the dataframe.
I know you can make the plot by calling df.plot(kind='bar')
. Here, .plot()
is a method of the df
.
HOWEVER, you can also make the plot by calling df.plot.bar()
. Here, .plot
is an attribute of the df
?
How is this possible that plot is both an attribute AND a method of the pandas df
. I tried creating a class in python with an attribute and method having the same name, but the method overwrote the attribute. Does anyone know?