当前位置: 首页 > news >正文

移动网站转码辽宁工程招投标信息网

移动网站转码,辽宁工程招投标信息网,广州网页制作培训,网站建设是半年的持久战背景 1、数据集下载 birthsHistorical US birth data culled from the CDC website - jakevdp/data-CDCbirthshttps://github.com/jakevdp/data-CDCbirths 2、数据集介绍 此数据来自美国疾病控制和预防中心,并通过 Google 的 BigQuery Web UI 使用以下查询进行编…

背景

1、数据集下载

birthsHistorical US birth data culled from the CDC website - jakevdp/data-CDCbirthsicon-default.png?t=O83Ahttps://github.com/jakevdp/data-CDCbirths

2、数据集介绍

此数据来自美国疾病控制和预防中心,并通过 Google 的 BigQuery Web UI 使用以下查询进行编译:

SELECTyear, month, day,IF (is_male, 'M', 'F') AS gender,SUM(record_weight) as births
FROM[publicdata:samples.natality]
GROUP BYyear, month, day, gender
ORDER BYyear, month, day, gender

它被汇总以符合他们的使用条款。 数据于 2015 年 6 月 9 日访问。

请注意,Andrew Gelman 和他的小组已经对这些数据进行了相当广泛的分析;参见 this post (英文)。

一、读取数据

import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
import pandas as pd
from datetime import datetime
%matplotlib inline

二、数据分析预处理

#假期对美国出生率的影响
births=pd.read_csv('./births.csv')
quartiles = np.percentile(births['births'], [25, 50, 75])
mu, sig = quartiles[1], 0.74 * (quartiles[2] - quartiles[0])
births = births.query('(births > @mu - 5 * @sig) & (births < @mu + 5 * @sig)')
births['day'] = births['day'].astype(int)
births.index = pd.to_datetime(10000 * births.year +100 * births.month +births.day, format='%Y%m%d')
births_by_date = births.pivot_table('births',[births.index.month, births.index.day])
births_by_date.index = [datetime(2012, month, day)for (month, day) in births_by_date.index]#导入datetime模块
births_by_date.index

DatetimeIndex(['2012-01-01', '2012-01-02', '2012-01-03', '2012-01-04',
               '2012-01-05', '2012-01-06', '2012-01-07', '2012-01-08',
               '2012-01-09', '2012-01-10',
               ...
               '2012-12-22', '2012-12-23', '2012-12-24', '2012-12-25',
               '2012-12-26', '2012-12-27', '2012-12-28', '2012-12-29',
               '2012-12-30', '2012-12-31'],
              dtype='datetime64[ns]', length=366, freq=None)

三、可视化

fig,ax=plt.subplots(figsize=(12,4)) 
births_by_date.plot(ax=ax)
ax.annotate("New Year's Day",xy=("2012-1-1",4100),xycoords='data',xytext=(50,-30),textcoords='offset points',         arrowprops=dict(arrowstyle='->',                 connectionstyle='arc3,rad=-0.2'))
ax.annotate("Independence Day",xy=('2012-7-4',4250),xycoords='data',          bbox=dict(boxstyle='round',fc='none',ec='gray'),         xytext=(10,-40),textcoords="offset points",ha='center',  arrowprops=dict(arrowstyle='->'))
ax.annotate("Labor Day",xy=('2012-9-4',4850),xycoords='data',ha='center',         xytext=(0,-20),textcoords='offset points')
ax.annotate('',xy=('2012-9-1',4850),xytext=('2012-9-7',4850),         xycoords='data',textcoords='data',   arrowprops={'arrowstyle':'|-|,widthA=0.2,widthB=0.2',})
ax.annotate('Halloween',xy=('2012-10-31',4600),xycoords='data',       xytext=(-80,-40),textcoords='offset points',        arrowprops=dict(arrowstyle='fancy',                     fc='0.6',ec='none',                       connectionstyle='angle3,angleA=0,angleB=-90'))
ax.annotate("Thanksgiving",xy=('2012-11-25',4500),xycoords='data',           xytext=(-120,-60),textcoords='offset points',           bbox=dict(boxstyle='round4,pad=.5',fc='0.9'),          arrowprops=dict(arrowstyle='->',                          connectionstyle='angle,angleA=0,angleB=80,rad=20'))
ax.annotate('Christmas',xy=('2012-12-25',3850),xycoords='data',           xytext=(-30,0),textcoords='offset points',           size=13,ha='right',va='center',           bbox=dict(boxstyle='round',alpha=0.1),         arrowprops=dict(arrowstyle='wedge,tail_width=0.5',alpha=0.1));
ax.set(title='USA births by day of year (1969-1988)',ylabel='average daily births')         
ax.xaxis.set_major_locator(mpl.dates.MonthLocator())
ax.xaxis.set_minor_locator(mpl.dates.MonthLocator(bymonthday=15))
ax.xaxis.set_major_formatter(plt.NullFormatter())
ax.xaxis.set_minor_formatter(mpl.dates.DateFormatter('%h'))
ax.set_ylim(3600,5400)
# ax.grid(True)
plt.show()

 

# Plot the results
fig, ax = plt.subplots(figsize=(8, 6))
births.groupby(dates)['births'].mean().plot(ax=ax)# Label the plot
ax.text('2012-1-1', 3950, "New Year's Day")
ax.text('2012-7-4', 4250, "Independence Day", ha='center')
ax.text('2012-9-4', 4850, "Labor Day", ha='center')
ax.text('2012-10-31', 4600, "Halloween", ha='right')
ax.text('2012-11-25', 4450, "Thanksgiving", ha='center')
ax.text('2012-12-25', 3800, "Christmas", ha='right')
ax.set(title='USA births by day of year (1969-1988)',ylabel='average daily births',xlim=('2011-12-20','2013-1-10'),ylim=(3700, 5400));# Format the x axis with centered month labels
ax.xaxis.set_major_locator(mpl.dates.MonthLocator())
ax.xaxis.set_minor_locator(mpl.dates.MonthLocator(bymonthday=15))
ax.xaxis.set_major_formatter(plt.NullFormatter())
ax.xaxis.set_minor_formatter(mpl.dates.DateFormatter('%h'));
ax.set_ylim(3600, 5400)plt.show()

 

http://www.yayakq.cn/news/761235/

相关文章:

  • 中山台州网站建设推广微信营销策略
  • 商城类网站模板做电子商务平台网站需要多少钱
  • 网站如何改字体58招聘网最新招聘信息
  • 建设销售型网站wordpress插件不生效
  • 湛江网站建设费用网站系统的建设与管理
  • 域名 网站名称肥城网站建设广州外地车牌
  • 网站制作的英文临沂google推广
  • 网站入口设计网站浏览排名
  • 南上海网站建设WordPress生成电商小程序
  • 外贸建站模板下载苏州网站建设老板
  • 先做网站还是先解析网站开发任务需求书
  • 做网站大概要多少建设企业网站进去无法显示
  • 赣州模板建站开发虚拟机wordpress插件
  • 建设配资网站有要求吗2016年网站推广方法
  • 建设银行etc的网站是哪个好一个营业执照可以做两个网站
  • 备案网站建设方案书范文网站登录不上怎么回事
  • 做网站怎么赚钱 知乎重庆网站建设找重庆万为
  • 地图设计网站招聘室内设计
  • 个人网站建设课程介绍保障房建设网站首页
  • 齐博网站模板上海icp新增网站
  • 公司网站建设设计公司排名哪个网站上网好
  • 做网站需要学的语言和软件广告建设网站建设
  • 外贸网站哪家好个人网页模板关于爱国
  • 网站分几种类型freeserver 免费服务器申请
  • 高密做网站哪家好价位自动发卡网和卡密兑换网站开发视频教程
  • 惠水网站建设吉林市网站建设
  • 网页设计 站点网页游戏开服表怎么关闭
  • wordpress网站好做排名吗家居网站建设总结
  • 智能手机网站模板金乡县网站开发
  • 最好的响应式网站曲靖建设局网站