I have a dataset of sold cars like this (by model):
model, year, price
Ford Focus, 2006, 5000
Ford Focus, 2000, 1500
I'd like to calculate several statistics ant plot them at the same image:
- average offer price by year
- year to year loose
- number of offers by year
I'm using pandas library to count statistics:
import pandas as pd
import matplotlib.pyplot as plt
#csv format
# model, year, price
# Ford Focus, 2004, 5000
cars = pd.read_csv(path)
focuses = cars[lambda x: x["model"] == "Ford Focus"]
avg_prices = focuses.groupby("year").mean()
offers_count = focuses.groupby("year").count()["price"]
avg_prices.plot()
offers_count.plot.bar(rot=0)
plt.title("Ford Focus")
plt.show()
But I have to images instead of one.
How to combine statistics to one image where plots has the same x axis (like stock charts)?