沐风数据2021 pyechart日历图

[复制链接]
作者: deepwind | 时间: 2021-5-28 16:27:14 | 数据分析|
0 50
发表于 2021-5-28 16:27:14| 显示全部楼层 |阅读模式

代码地址:

https://github.com/deepwindlee/MySQL-with-Python-DATA-MINING/blob/master/My_excel/%E6%B2%90%E9%A3%8E%E6%95%B0%E6%8D%AE2021%20pyechart%E6%97%A5%E5%8E%86%E5%9B%BE.ipynb

读取一年的数据, 并重命名各列

data_dir = r'C:\\Users\\mydeepwind\\Desktop\\HS\\xx周报\\国控站数据累计天数2021.xlsx'
df = pd.read_excel(data_dir,skiprows=1)

DF =df[['Unnamed: 0','Unnamed: 13' ,'Unnamed: 14']].rename(columns={'Unnamed: 0':'DAY','Unnamed: 13':'AQI','Unnamed: 14':'MAIN'})
.drop(index=[0])#[['空气质量指数(AQI)']]
DF['DAY']= DF['DAY'].astype(str)

加载pyecharts

版本为 1.6

配置颜色,层级

from datetime import datetime
import glob
from datetime import datetime, timedelta
import numpy as np
import pandas as pd

from matplotlib import cm, colors
import matplotlib.dates as mdates
import matplotlib.patches as mpatches
import matplotlib.pyplot as plt

begin = datetime(2021, 1, 1)
end = datetime(2021, 12, 31)

data = [
    [str(begin + timedelta(days=i)), AQI_list[i]]
    for i in range((end - begin).days + 1)
]

colors_aqi = ['#009966', '#FFDE33', '#FF9A32', '#CC0033', '#660099']
levels = [0, 50, 100, 150, 200, 300]

cmap_aqi = colors.ListedColormap(colors_aqi)  
norm = colors.BoundaryNorm(levels, cmap_aqi.N)

最后的效果为

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

!jz_fbzt! 快速回复 !jz_sctz! !jz_fhlb! 按钮
快速回复 返回列表 返回顶部