A simple API key example package
Project description
📦 Weather Data Client
This package includes a function to fetch and preprocess historical weather data from Weatherunderground.com.
Installation
pip install get-weather-api
📘 Usage
For a single month, the data is correct.
from get_weather.client import get_weather_data
import os
os.environ["API_KEY"] = "API_KEY"
df = get_weather_data(
weather_station="RJAA",
country_code="JP",
startDate="20190201",
endDate="20190301",
timezone="US/Pacific"
)
print(df.head())
However, for multiple months, you need to split the queries and concatenate it after.
starts = pd.date_range(start='20220101', end='20230301', freq="ME")
ends = pd.date_range(start='20220101', end='20230301', freq="ME")
starts = [s.replace(day=1) for s in starts]
s_e = zip(starts, ends)
df_arr = []
for s, e in s_e:
s = s.strftime("%Y%m%d")
e = e.strftime("%Y%m%d")
df = c.get_weather_data(
startDate=s,
endDate=e,
weather_station="KCHA",
timezone="US/Eastern",
country_code="US",
number=2
)
df_arr.append(df)
df = pd.concat(df_arr)
Parameters
Parameters can be obtained from https://www.wunderground.com/. For a desired location follow these steps.
- Search locations in the upper right. For example Manila, Philippines.
- Click the history tab and identify the weather station which would be the last parameter in the URL:
Here it would be RPLL.https://www.wunderground.com/history/daily/ph/manila/RPLL - The country code would be the third to the last parameter:
PH - Timezone would be what you want the data to be encoded in, for Manila it would be
'Asia/Manila' - Start and end dates must be strings in the form of
YYYYMMDD. The minimum window should be 1 month. i.e.,20201001to20201101.
Thus the arguments you would use would be:
df = get_weather_data(weather_station="RPLL", country_code="PH", startDate="20201001", endDate="20201101", timezone="Asia/Manila")
📊 Weather Feature Descriptions
| Column | Description |
|---|---|
| Time | The timestamp of the weather observation, converted from GMT to your specified timezone. This is usually reported in hourly intervals and used as the index for the DataFrame. |
| tempf | Air temperature in degrees Fahrenheit at the time of observation. |
| dewPt | Dew point in degrees Fahrenheit – the temperature at which air becomes saturated and dew can form. Used to assess humidity. |
| rh | Relative Humidity in percentage (%). Indicates how much moisture is in the air compared to the maximum possible at that temperature. |
| wdir_cardinal | Wind direction as a cardinal compass point (e.g., "N", "NE", "W"). Reflects the direction from which the wind is blowing. |
| wspd | Wind speed in miles per hour (mph). Average wind speed during the observation window. |
| gust | Wind gust in mph. Peak wind speed recorded during the observation window. May be missing or zero if conditions were calm. |
| pressure | Atmospheric pressure in inches of mercury (inHg). Often used in weather forecasting (e.g., identifying high/low pressure systems). |
| precip | Total precipitation during the hour in inches (rain, snow water equivalent, etc.). May be "0.0" if no measurable precipitation occurred. |
| wx_phrase | Textual weather summary, e.g., "Partly Cloudy", "Rain Showers", "Snow", etc. Useful for quick human-readable interpretation of the weather conditions. |
🔧 Setup
-
Create a
.envfile with your API key:echo "API_KEY=your_actual_api_key_here" > .env
-
Install the package:
pip install .
-
(Optional) Install dev dependencies:
pip install .[dev]
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file get_weather_api-0.1.3.tar.gz.
File metadata
- Download URL: get_weather_api-0.1.3.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a2b07b3330f51f44b3997df43323aafad21dd682be7188e41eeefa1ae3dbda9
|
|
| MD5 |
fa9f889ca4816b01f7fc0359a073d38e
|
|
| BLAKE2b-256 |
b5dc3d52df5d94577b2c6d6df122d5dc3b2efc51ac9ca7e58c4bd4a8241a2944
|
File details
Details for the file get_weather_api-0.1.3-py3-none-any.whl.
File metadata
- Download URL: get_weather_api-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6dbe4acb8360824e0699032c0d1b65fdb635fd13e5d94c8d822f3609f31e6b70
|
|
| MD5 |
6f1376df424933db88aaf52bece2241c
|
|
| BLAKE2b-256 |
d768ba1eed7beb4494ff90710214a37a1d75af0eacbd6949249ef6bedeedb321
|