Created
October 24, 2020 19:22
-
-
Save chaudum/14351a23be7278d1d34fd523a6f0eed0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pip install wetterdienst==0.9.0 crate[sqlalchemy] | |
# pip install cr8 | |
# | |
# Usage: | |
# cr8 run-crate 4.2.x | |
# python example.py | |
from sqlalchemy import create_engine | |
from wetterdienst import DWDObservationData | |
from wetterdienst import Parameter, PeriodType, TimeResolution | |
if __name__ == "__main__": | |
engine = create_engine("crate://localhost:4200") | |
observations = DWDObservationData( | |
station_ids=[1048], | |
parameter=[Parameter.TEMPERATURE_AIR], | |
time_resolution=TimeResolution.HOURLY, | |
start_date="2019-01-01", | |
end_date="2020-01-01", | |
tidy_data=True, | |
humanize_column_names=True, | |
) | |
df = observations.collect_safe().dwd.lower() | |
df.to_sql("weather", engine, "doc", if_exists="append", index=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment