Time Series
Meteostat provides access to time series data for thousands of weather stations worldwide. These time series are provided in different granularities and can be consumed through a single interface.
🚀 Example#
🎯 Location Input#
Every time series function takes the location as its first argument: one or more weather stations, or geographical points.
| Input | Use it when |
|---|---|
| Station ID, or a list of IDs | You know the stations' Meteostat IDs |
Station object(s) |
You want to provide station metadata yourself, e.g. for stations not in the Meteostat database |
DataFrame of stations |
You looked stations up first, e.g. with ms.stations.nearby (index named id) |
Point object(s) |
You need data for a location rather than a station |
Python
from datetime import datetime
import meteostat as ms
START = datetime(2024, 1, 1)
END = datetime(2024, 1, 31, 23, 59)
# Station ID(s)
ts = ms.hourly('10637', START, END)
ts = ms.hourly(['10637', '10635'], START, END)
# Station object with your own metadata
station = ms.Station(
id='10637',
name='Frankfurt Airport',
country='DE',
region='HE',
lat=50.05,
lon=8.6842,
elevation=100
)
ts = ms.hourly(station, START, END)
# The four stations closest to a location
stations = ms.stations.nearby(ms.Point(50.1155, 8.6842, 113), limit=4)
ts = ms.hourly(stations, START, END)
# A geographical point (needs a provider that supports points)
point = ms.Point(50.05, 8.6842, 100)
ts = ms.hourly(point, START, END, providers=[ms.Provider.METNO_FORECAST])🔀 Merging Time Series#
ms.merge combines several time series into one, for example data you fetched in
separate requests. The time series must have the same granularity, and hourly time series the same time zone.
Python
from datetime import date
import meteostat as ms
# Two consecutive periods for New York LaGuardia Airport
ts1 = ms.daily('72503', date(2020, 1, 1), date(2020, 1, 10))
ts2 = ms.daily('72503', date(2020, 1, 11), date(2020, 1, 20))
ts = ms.merge([ts1, ts2])
# One DataFrame covering January 1–20
df = ts.fetch()
print(df)👀 Learn More#
Hourly WeatherIf you want to investigate the weather on a particular day or a short period of time, hourly time series data is a great choice.Daily WeatherDaily time series data is ideal for analyzing weather patterns over longer periods, such as weeks, months, or years.Monthly WeatherMonthly time series data is perfect for examining long-term climate trends and seasonal patterns over extended periods, such as years or decades.