def aqi_get_daily_aqi(): df = aqi.get_daily_aqi(date=request.form['date']) print(df) return df.to_json(orient='table')
# encoding: utf-8 from opendatatools import aqi from pyecharts import Geo import pandas as pd if __name__ == '__main__': df_aqi = aqi.get_daily_aqi('2018-05-27') df_aqi.to_csv("aqi_daily.csv") #df_aqi = pd.read_csv("aqi_daily.csv") # some city cannot by process by echart echart_unsupported_city = [ "菏泽市", "襄阳市", "恩施州", "湘西州", "阿坝州", "延边州", "甘孜州", "凉山州", "黔西南州", "黔东南州", "黔南州", "普洱市", "楚雄州", "红河州", "文山州", "西双版纳州", "大理州", "德宏州", "怒江州", "迪庆州", "昌都市", "山南市", "林芝市", "临夏州", "甘南州", "海北州", "黄南州", "海南州", "果洛州", "玉树州", "海西州", "昌吉州", "博州", "克州", "伊犁哈萨克州" ] data = [] for index, row in df_aqi.iterrows(): city = row['city'] aqi = row['aqi'] if city in echart_unsupported_city: continue data.append((city, aqi))
def test_get_daily_aqi(self): df = aqi.get_daily_aqi('2018-01-01') assert(len(df)>0)