Openweathermap requests fetch weather history pandas datframe

openweathermap_requests的Python项目详细描述


Latest VersionSupported Python versionsWheel formatLicenseDevelopment StatusDownloads monthlyDocumentation StatusSourcegraphGitterCode HealthBuild Status

OpenWeatherMap请求

Python要从中获取数据的包 OpenWeatherMap.org使用 RequestsRequests-cache然后 Pandas DataFrame有气象记录。

命令行界面使用

当前天气

获取当前天气数据

$ python openweathermap_requests.py --lon 0.34189 --lat 46.5798114

历史天气数据

从最近的气象站获取历史气象数据 2014/01/01至2014/12/01坐标(lon=0.34189,lat=46.5798114) 使用:

$ python openweathermap_requests.py --lon 0.34189 --lat 46.5798114 --range 20140101:20141201

库使用

import datetime
import logging
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
from openweathermap_requests import OpenWeatherMapRequests

ow = OpenWeatherMapRequests(api_key='', cache_name='cache-openweathermap', expire_after=5*60)

(lon, lat) = (0.34189, 46.5798114) # Poitiers

data = ow.get_weather(lon=lon, lat=lat)  # display current weather data
print(data)

stations = ow.find_stations_near(lon=lon, lat=lat, cnt=10) # get 10 nearest stations from coordinates (lon, lat)

station_id = stations.iloc[0]['station.id'] # get station_id of nearest station

start_date = datetime.datetime(2014, 1, 1)
end_date = datetime.datetime(2014, 6, 1)

data = ow.get_historic_weather(station_id, start_date, end_date) # get historic weather from start date to end date
print(data)

安装

来自python包索引
$ pip install openweathermap_requests

源代码

使用git获取最新版本

$ git clone https://github.com/scls19fr/openweathermap_requests.git
$ cd openweathermap_requests
$ python setup.py install

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何在springmvc POST webservice中验证集合?   java将变量传递到@Optional注释   浮点Java字节到浮点   java为什么我的结果字符串在解析json数据后不打印到logcat?   多线程应用程序中的java可选调试输出是为客户机提供的,而不是为了找出死锁或bug   java Hibernate模型对象作为VO对象   java字体未应用于复选框并切换到Android Studio 3   list Java equals方法无法按预期工作   java将未知对象强制转换为特定接口可以吗?   调用后未擦除方法中的Java变量   数组求和不正确,线程“main”java中出现异常。lang.ArrayIndexOutofBounds异常:100   java超级类应该实例化并调用其子类吗?   在java apache中。平民io,如何避免读取旧的日志消息   BuffereImage如何使用apache在TIFF图像中保持透明性。平民java中的图像处理   java转换。将文件分类为二进制代码(1和0)   Java:。类搜索器   java如何使用谓词生成器返回“Todays Orders”