def cn_total(): covid_19_163_df = ak.covid_19_163(indicator="中国历史累计数据") print(covid_19_163_df) covid_19_163_df.to_csv(r'../Data/csv/ak中国历史累计数据.csv', encoding='utf-8')
def global_real(): covid_19_163_df = ak.covid_19_163(indicator="世界历史累计数据") print(covid_19_163_df) covid_19_163_df.to_csv(r'../Data/csv/ak世界历史累计数据.csv', encoding='utf-8')
import akshare as ak covid_19_163_df = ak.covid_19_163(indicator="世界历史累计数据") print(covid_19_163_df) covid_19_163_df.to_csv("世界历史累计数据.csv")
# coding=gbk import json from operator import itemgetter import numpy as np import akshare as ak from pyecharts.charts import Map, Line, Grid, Timeline, Bar, Pie from pyecharts import options as opts date_span_1 = ['2020-02-0' + str(i) for i in range(8, 10)] date_span_2 = ['2020-02-' + str(i) for i in range(10, 22)] date_span = date_span_1 + date_span_2 time_list = [item[-5:] for item in date_span] # 截取所选的两周全国数据 df_covid_total = ak.covid_19_163(indicator="中国历史时点数据") df_covid_total = df_covid_total.loc[date_span, :] # 处理为pyecharts接受的格式 confirmed = [int(x) for x in np.array(df_covid_total['confirm'])] suspected = [int(x) for x in np.array(df_covid_total['suspect'])] healed = [int(x) for x in np.array(df_covid_total['heal'])] death = [int(x) for x in np.array(df_covid_total['dead'])] # get每日的分省份详细信息 with open('epidata.json', 'r') as f: prov_data = json.loads(f.read()) def get_processed_data(date: str): processed_data = [] for d in prov_data:
for i in range(0,8): temp=ts.get_hist_data(list[i],start='2006-12-22',end='2018-12-29', ktype='W') pta[list[i]]=temp.close pta.to_excel("E:/02_paper/杨老师/data/pta.xlsx") # 2.获取实时票房 import tushare as ts df = ts.realtime_boxoffice() print(df.MovieName) print(df) # 3.获取疫情数据 import akshare as ak #中国疫情历史数据 CN = ak.covid_19_163(indicator="中国历史累计数据") #中国新增数据 CN_NEW = ak.covid_19_163(indicator="中国历史时点数据" #全球疫情最新数据 WORLD = ak.covid_19_baidu(indicator="国外分国详情") WORLD = WORLD[['area','confirmed','died','crued']] #国外分城市数据 CITY = ak.covid_19_baidu(indicator="国外分城市详情") #美国疫情数据 data = pd.read_html('https://covidtracking.com/data/us-daily/')[0] from urllib import request
''' akshare data collecter''' '''https://www.akshare.xyz/zh_CN/latest/data/event/event.html''' import akshare as ak import pandas covid_19_China_daily = ak.covid_19_163(indicator="中国实时数据") covid_19_China_history = ak.covid_19_163(indicator="中国历史时点数据") covid_19_China_history_total = ak.covid_19_163(indicator="中国历史累计数据") covid_19_global_history = ak.covid_19_163(indicator="世界历史时点数据") covid_19_global_history_total = ak.covid_19_163(indicator="世界历史累计数据") covid_19_all_area_history_total = ak.covid_19_163(indicator="全球所有国家及地区累计数据") #covid_19_city_SH_history = ak.covid_19_hist_city(city = "上海市") #covid_19_history_all = ak.covid_19_history() covid_19_China_daily.to_csv("covid_19_China_daily.csv") covid_19_China_history.to_csv("covid_19_China_daily.csv") covid_19_China_history_total.to_csv("covid_19_China_history_total.csv") covid_19_global_history.to_csv("covid_19_global_history.csv") covid_19_global_history_total.to_csv("covid_19_global_history_total.csv")
import akshare as ak covid_19_163_df = ak.covid_19_163(indicator="中国历史时点数据") print(covid_19_163_df)