Home > OS >  How do I create plot in pandas?
How do I create plot in pandas?

Time:09-30

I am fairly new to Python and I am trying to understand how to make a plot for:

df.groupby('battery').weight.mean()

How would I go about creating a plot(specifically a line plot to compare the battery size to mean weight)? Thank you for your help!

CodePudding user response:

It would be easier if you had provided a example dataset.

However, if I understand correctly, you can use pandas' plot method (plot.line in this case):

df.groupby('battery')['weight'].mean().plot.line()

output:

pandas line plot

CodePudding user response:

Pandas is a library basically used for Data Analysis, so you can read data, processes data and store them in in various format using Pandas Dataframe. If you would like to plot your data visually, then matplotlib will be a good opt in for plotting and visualization.

  • Related