# encoding: utf-8 from opendatatools import aqi # 获取某日全国各大城市的AQI数据 #aqi.get_daily_aqi('2018-01-01') # 获取单个城市的AQI历史数据 #aqi.get_daily_aqi_onecity('北京市') #获取单个城市某日的AQI小时数据 #aqi_hour = aqi.get_hour_aqi_onecity('北京市', '2018-05-26') #aqi_hour.set_index('time', inplace=True) #print(aqi_hour) #获取实时AQI小时数据 aqi_hour = aqi.get_hour_aqi() print(aqi_hour)
def test_get_hour_aqi(self): aqi_hour = aqi.get_hour_aqi() assert (len(aqi_hour) > 0)
def aqi_get_hour_aqi(): df = aqi.get_hour_aqi() return df.to_json(orient='table')
from PyQt5 import QtCore, QtWidgets from qtpy.QtCore import QUrl from qtpy.QtWebEngineWidgets import QWebEngineView from pyecharts import Geo,Line import datetime import sys from opendatatools import aqi import pandas as pd sys.setrecursionlimit(5000) local='长沙市' lastcity='' nowTime=(datetime.datetime.now()-datetime.timedelta(hours=1)).strftime('%Y-%m-%d %H')#现在 day=(datetime.datetime.now()-datetime.timedelta(hours=1)).strftime('%Y-%m-%d')#当天 print (nowTime) df_aqi = aqi.get_hour_aqi(nowTime) aqi_hour = aqi.get_hour_aqi_onecity(local, day) df_aqi.to_csv('aqi.csv') aqi_hour.to_csv('daylocal.csv') df_aqi=pd.read_csv('aqi.csv') aqi_hour=pd.read_csv('daylocal.csv') print (df_aqi) print (aqi_hour) class Ui_Form(object): def setupUi(self, Form): Form.setObjectName("Form") Form.resize(442, 824) Form.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) Form.setWindowFlags(QtCore.Qt.CustomizeWindowHint)