如果id不是字符串型需要先转化为字符串才行,title加标题,subplots设置日期斜着显示
pp = pd.DataFrame({"id":["1001", "1001", "1001",
"1002", "1002", "1002", '1002',
"1003", "1003", "1003", '1003', '1003'],
"day":["2018-7-15", "2018-7-16","2018-7-18",
"2018-7-15", "2018-7-16","2018-7-18", "2018-7-19",
"2018-7-15", "2018-7-16","2018-7-18", "2018-7-19","2018-7-22"],
"kg":[68, 64, 56,
68, 64, 56, 78,
68, 64, 56,56, 65]})
pp = pp.set_index('day')
pp.groupby("id").plot()
for name, group in pp.groupby("id"):
group.plot(title="id:"+name,subplots=True)
网友评论