python机器学习-乳腺癌细胞挖掘(博主亲自录制视频)

https://study.163.com/course/introduction.htm?courseId=1005269003&utm_campaign=commission&utm_source=cp-400000000398149&utm_medium=share

医药统计项目联系QQ:231469242

All rights reversed
 commercial use not allowed

北京数据

重庆数据

美国Rockwell

澳大利亚悉尼

印尼雅加达

London 英国

# -*- coding: utf-8 -*-
# All rights reversed, commercial use not allowed
#! python3
# quickWeather.py - Prints the current weather for a location from the command line.
"""
k(开尔文)=273.15+T(摄氏度) json返回的是开尔文温度
Created on Sat Apr 16 10:24:28 2016 @author: daxiong
""" import json, requests,sys,pylab,numpy #城市名称
cityName="beijing"
#城市ID号
cityID="2038349"
#我的免费appID
appID="0383ae59663e14ab5a6855d5b6ad5d00"
#获取时间段数
cnt="30"
# Download the JSON data from OpenWeatherMap.org's API
url="http://api.openweathermap.org/data/2.5/forecast/city?id=%s&APPID=%s&cnt=%s"%(cityID,appID,cnt)
response = requests.get(url)
response.raise_for_status() # Load JSON data into a Python variable.
weatherData = json.loads(response.text) # Print weather descriptions.
#主要获取weatherData---weather---main和description信息
w = weatherData['list']
print('Current weather in %s:' % (cityName)) temperature_list=[]
cnt_list=[]
time_list=[]
for i in range(int(cnt)):
time=w[i]['dt_txt']
print(time)
main=w[i]['weather'][0]['main']
description=w[i]['weather'][0]['description']
temp=w[i]['main']['temp']
temp_Chinese=temp-273.15
temp_Chinese_round=round(temp_Chinese,2)
temperature_list.append(temp_Chinese_round)
cnt_list.append(i+1)
time_list.append(str(time))
print(main, '-',description,'-',temp_Chinese_round,"摄氏度")
print() barwidth=0.5
pylab.bar(cnt_list,temperature_list,width=barwidth,color='y')
pylab.xlabel("times")
pylab.ylabel('temperature')
pylab.title("%s temperature prediction(x axis every 3 hours per tickt)"%cityName)
pylab.show() #计算最高气温和最低气温
list_temperature_time=zip(temperature_list,time_list)
dict_temperature_time=dict(list_temperature_time)
max_temp=max(dict_temperature_time.keys())
min_temp=min(dict_temperature_time.keys())
print("最高气温:",max_temp,'摄氏度','-',dict_temperature_time[max_temp])
print("最低气温:",min_temp,'摄氏度','-',dict_temperature_time[min_temp]) #温差列表,用于统计哪天人最容易生病
temperature_difference_list=[]
for i in range(len(temperature_list)-1):
temperature_difference=temperature_list[i+1]-temperature_list[i]
temperature_difference_list.append(temperature_difference) time_difference_list=[]
for i in range(len(time_list)-1):
time_difference=time_list[i]+'-'+time_list[i+1]
time_difference_list.append(time_difference) list_temperature_time_difference=zip(temperature_difference_list,time_difference_list)
dict_temperature_time_difference=dict(list_temperature_time_difference)
max_temp_difference=max(dict_temperature_time_difference.keys())
min_temp_difference=min(dict_temperature_time_difference.keys())
print("最高温差:",round(max_temp_difference,2),'摄氏度','-',dict_temperature_time_difference[max_temp_difference])
print("最低温差:",round(min_temp_difference,2),'摄氏度','-',dict_temperature_time_difference[min_temp_difference]) #最容易生病时间段,取温差绝对值最大的key
if abs(max_temp_difference)>abs(min_temp_difference):
ill_likely_day=dict_temperature_time_difference[max_temp_difference]
else:
ill_likely_day=dict_temperature_time_difference[min_temp_difference]
print("最容易生病时间段:",ill_likely_day) #统计温差又高到底排序的时间段
#温差绝对值列表
absolute_temperature_difference_list=[abs(i) for i in temperature_difference_list]
list_temperature_time_difference=zip(absolute_temperature_difference_list,time_difference_list)
dict_absolute_temperature_time_difference=dict(list_temperature_time_difference)
sorted_temperature_time_difference=sorted(dict_absolute_temperature_time_difference.items(),reverse=True) '''
# Compute location from command line arguments.
if len(sys.argv) < 2:
print('Usage: quickWeather.py location')
sys.exit()
location = ' '.join(sys.argv[1:]) len(weatherData)
Out[21]: 5
for i in weatherData:
print(i)
city #城市信息
cod #内部参数
cnt #预测天数
list #信息列表,主要获取weatherData---weather---main和description信息
message #内部参数 weatherData
Out[23]:
{'city': {'coord': {'lat': 30.25, 'lon': 107.75},
'country': 'CN',
'id': 1814905,
'name': 'Chongqing Shi',
'population': 0,
'sys': {'population': 0}},
'cnt': 1,
'cod': '200',
'list': [{'clouds': {'all': 44},
'dt': 1460775600,
'dt_txt': '2016-04-16 03:00:00',
'main': {'grnd_level': 937.55,
'humidity': 98,
'pressure': 937.55,
'sea_level': 1025.81,
'temp': 288.16,
'temp_kf': 0.4,
'temp_max': 288.16,
'temp_min': 287.759},
'rain': {'3h': 0.01},
'sys': {'pod': 'd'},
'weather': [{'description': 'light rain',
'icon': '10d',
'id': 500,
'main': 'Rain'}],
'wind': {'deg': 267.501, 'speed': 1.63}}],
'message': 0.0109} #pylab.hist(temperature_list)
pylab.plot(cnt_list,temperature_list,'ro')
pylab.xlabel("times")
pylab.ylabel('temperature')
pylab.title("%s temperature prediction"%cityName)
pylab.show()
'''

  

 https://study.163.com/provider/400000000398149/index.htm?share=2&shareId=400000000398149( 欢迎关注博主主页,学习python视频资源,还有大量免费python经典文章)

获取天气预报API5_统计最容易生病时间段的更多相关文章

  1. [整]C#获取天气预报信息(baidu api)包括pm2.5

    /// <summary> /// 获取天气预报信息 /// </summary> /// <returns></returns> public Bai ...

  2. java获取天气预报的信息

    运行效果: 主要功能: 1,jsp页面输入省份和城市 根据条件获取当地的天气信息 2,java代码 利用第三方的省份和城市的路径地址 本工程主要实现java获取天气预报的信息步骤1,创建工程weath ...

  3. Android 获取天气预报

    界面布局 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android ...

  4. php从气象局获取天气预报并保存到服务器

    思路:1.打开网页时读取中国气象网的接口得到每个城市的该日json:2.解析并保存到mysql:3.客户端访问mysql得到数据集. 所包含的技巧: 进度条.flush()问题.mysql.xml.p ...

  5. 获取分组后统计数量最多的纪录;limit用法;sql执行顺序

    CREATE TABLE emp(id INT PRIMARY KEY,NAME VARCHAR(11),dep_id INT ,salary INT); CREATE TABLE dept(id I ...

  6. springboot 采用HttpClient获取天气预报 异常及原因

    采用httpClient调用天气预报地址获取出现异常 2018-10-04 15:18:25.815 ERROR 10868 --- [nio-8080-exec-5] o.a.c.c.C.[.[.[ ...

  7. php获取本周、本月、本年的时间段

    这是在TP框架里面自己用到的一个获取周.月.年时间段的方法.

  8. Ajax的封装,以及利用jquery的ajax获取天气预报

    1.Ajax的封装 function ajax(type,url,param,sync,datetype,callback){//第一个参数是获取数据的类型,第二个参数是传入open的url,第三个是 ...

  9. vc中获取磁盘IO统计计数

    想知道进程读写磁盘的情况,可以获取当前进程或指定进程的IO计数. #include <Windows.h> int get_io_bytes(ULONGLONG * read_bytes, ...

随机推荐

  1. js 基础-&& || 逻辑与和逻辑或

    今天百度发现一个简化长if   else if 语句的方法,看起来及其强大,感觉这样虽然对系统性能提升没有帮助但是代码更简练了,分析了一番,下面先说说自己学到的理论. 首先要弄清楚js 中对于 变量, ...

  2. github心得体会 王倩倩 201303014004 计科高职13-1

    刚开始接触一门语言软件特别无从下手,尤其还是全英文的,真的是很头疼,注册的时候这个就弄了半天,在网上搜了一下教程然后又结合着老师上课讲的内容自己多做了几遍,也算是对github熟悉了,然后学会操作代码 ...

  3. Leetcode 712. 两个字符串的最小ASCII删除和

    题目描述: https://leetcode-cn.com/problems/minimum-ascii-delete-sum-for-two-strings/ 解题思路: 也是典型的dp问题.利用二 ...

  4. Linux入门笔记

    1.Linux常用快捷键 按键 作用 Ctrl+d 键盘输入结束或退出终端 Ctrl+s  暂停当前程序,暂停后按下任意键恢复运行 Ctrl+z 将当前程序放到后台运行,恢复到前台为命令fg Ctrl ...

  5. 【Alpha发布】网站已经正式发布!

    Alpha版本发布说明 一.功能介绍 本团队所做的物理实验网站是以生成物理实验报告为基础功能的网站.Alpha版本具有的功能大体如下: Figure 1首页 1. 注册登录功能 用户可以通过在注册页通 ...

  6. JavaScript 作用域链与闭包

    作用域链 在某个作用域访问某个变量或者函数时,会首先在自己的局部环境作用域中搜寻变量或者函数,如果本地局部环境作用域中有该变量或者函数,则就直接使用找到的这个变量值或者函数:如果本地局部环境作用域中没 ...

  7. Angular 简单的Get

    <!DOCTYPE html><html ng-app="myApp"><head lang="en"> <meta ...

  8. indicator function指示函数

    指示函数   在集合论中,指示函数是定义在某集合X上的函数,表示其中有哪些元素属于某一子集A. 中文名 指示函数 外文名 indicator function 相关学科 数学.组合数学 其他称呼 特征 ...

  9. 快乐的Lambda表达式(二)

    转载:http://www.cnblogs.com/jesse2013/p/happylambda-part2.html 快乐的Lambda表达式 上一篇 背后的故事之 - 快乐的Lambda表达式( ...

  10. MT【227】换钱的总数

    (2012复旦)将1张面值100元的人民币全部换成面值1角,2角,5角的人民币,不同的换法有多少种? 解:即求不等式$2x+5y\le1000$的所有非负整数解的个数.由匹克公式:$S=a+\dfra ...