Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 一次画多幅图_Python_Pandas_Matplotlib - Fatal编程技术网

Python 一次画多幅图

Python 一次画多幅图,python,pandas,matplotlib,Python,Pandas,Matplotlib,我想使用matplotlib和pandas绘制绘图。 在熊猫中,我有价格数据和该价格的日期。所有年份都在一个文件中。在图中,我想得到许多图,用于比较涨价/降价的月份,每种颜色都意味着某一年。 因此,我的问题是,从matplotlib或pandas到不每年提取和其他小问题,有没有简单的解决方案?答案是“pivot\u table” 因此,类似任务的代码如下所示: url="https://hotline.ua/temp/charts/102320/63price.csv" fixed_df_t

我想使用matplotlib和pandas绘制绘图。 在熊猫中,我有价格数据和该价格的日期。所有年份都在一个文件中。在图中,我想得到许多图,用于比较涨价/降价的月份,每种颜色都意味着某一年。 因此,我的问题是,从matplotlib或pandas到不每年提取和其他小问题,有没有简单的解决方案?

答案是“pivot\u table” 因此,类似任务的代码如下所示:

url="https://hotline.ua/temp/charts/102320/63price.csv"

fixed_df_t = pd.read_csv(url, sep=';', parse_dates=[0], 
                         dayfirst=True, names=["Date", "Price"], 
                                        index_col='Date')

r = fixed_df_t[['Price']].assign(year=fixed_df.index.year, 
                                 month=fixed_df.index.month) \
                .pivot_table(index='month', columns='year',
                             values='Price', aggfunc='mean')

r.plot(legend=True, figsize=(15, 10))
您应该提供您的数据(或示例)和迄今为止您试图解决问题的代码。@DavideBrex示例: