跳转到主要内容

openweathermap请求获取天气历史Pandas DataFrame

项目描述

Latest Version Supported Python versions Wheel format License Development Status Downloads monthly Documentation Status Sourcegraph Gitter Code Health Build Status

OpenWeatherMap Requests

Python 包,用于使用 OpenWeatherMap.orgRequestsRequests-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

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪一个,请了解有关安装包的更多信息。

源分发

openweathermap_requests-0.0.5.tar.gz (6.4 kB 查看哈希值)

上传时间

构建分发

openweathermap_requests-0.0.5-py2.py3-none-any.whl (8.5 kB 查看哈希值)

上传时间 Python 2 Python 3

由...