peers_per_site.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:zeronet-easymetrics 作者: kostaNew 项目源码 文件源码
def default(general, task, scope):

    #Read and clean data
    data = pd.read_csv(os.path.join(general["folder"], general["zite_data"]))
    data = clean_additional_header(data)
    data['time'] = pd.to_datetime(data['time'], format="%Y-%m-%d_%H-%M-%S")
    data['peers_total'] = data['peers_total'].astype('int')

    #Peers by time
    plot_series = []
    for el in scope:
        zite_name = el['zite']
        temp_ = data[data.address == zite_name][['time','peers_total']].sort_values(by='time')
        plot_series.append({'time':temp_['time'], 'peers_total':temp_['peers_total'], 'label':el['label']})

    #Plots
    fig = plt.figure()
    ax = plt.subplot(111)

    for p in plot_series:
        ax.plot(p['time'], p['peers_total'], label=p['label'])

    plt.xticks(rotation=15) 

    majorFormatter = matplotlib.dates.DateFormatter('%m-%d %H:%M:%S')
    ax.xaxis.set_major_formatter(majorFormatter)
    ax.autoscale_view()

    ax.legend(loc='upper center', bbox_to_anchor=(0.5, 1.1),
          ncol=3, fancybox=True, shadow=True)

    plt.show()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号