I have following set of data:
import pandas as pd
import matplotlib as mlp
import matplotlib.pyplot as plt
nameLst = ['a', 'b', 'c', 'a', 'b', 'c', 'a', 'b', 'c']
priceLst = [3, 1, 5, 2, 3, 6, 1, 8, 3]
dateLst = [1, 1, 1, 2, 2, 2, 3, 3, 3]
df = pd.DataFrame(columns = ['name', 'price', 'date'])
df['name'] = nameLst
df['price'] = priceLst
df['date'] = dateLst
name price date
0 a 3 1
1 b 1 1
2 c 5 1
3 a 2 2
4 b 3 2
5 c 6 2
6 a 1 3
7 b 8 3
8 c 3 3
And I want to create a seperate plot graphs for each name where x-axis contains date values and y-axis contains price values. I believe this code should do the work but I'm getting following error:
ValueError: The name date occurs multiple times, use a level number
Can you show me what I'm doing wrong?
for name, gp in df.groupby(['name']):
fig, ax = plt.subplots()
gp.pivot(index='date', columns='date', values='price').plot(ax=ax, marker='o', title=name)
plt.show()

