blob: 22af0b9a21ad867f6c75f9fd32540c3b0062676f [file] [log] [blame]
Marc Kupietz12a9fe82020-06-16 14:27:57 +02001#!/usr/bin/env python3
Marc Kupietz6d539742020-06-25 18:33:20 +02002from KorAPClient import KorAPClient, KorAPConnection
Marc Kupietz12a9fe82020-06-16 14:27:57 +02003import plotly.express as px
Marc Kupietz12a9fe82020-06-16 14:27:57 +02004
5QUERY = "Hello World"
6YEARS = range(2010, 2019)
7COUNTRIES = ["DE", "CH"]
8
Marc Kupietz6d539742020-06-25 18:33:20 +02009kcon = KorAPConnection(verbose=True)
Marc Kupietz12a9fe82020-06-16 14:27:57 +020010
11vcs = ["textType=/Zeit.*/ & pubPlaceKey=" + c + " & pubDate in " + str(y) for c in COUNTRIES for y in YEARS]
Marc Kupietz6d539742020-06-25 18:33:20 +020012df = KorAPClient.ipm(kcon.frequencyQuery(QUERY, vcs))
13print(df)
14
Marc Kupietz12a9fe82020-06-16 14:27:57 +020015df['Year'] = [y for c in COUNTRIES for y in YEARS]
16df['Country'] = [c for c in COUNTRIES for y in YEARS]
Marc Kupietz33146542021-06-18 12:32:38 +020017df['error_y'] = df["conf.high"] - df["ipm"]
18df['error_y_minus'] = df["ipm"] - df["conf.low"]
Marc Kupietz12a9fe82020-06-16 14:27:57 +020019
20fig = px.line(df, title=QUERY, x="Year", y="ipm", color="Country",
Marc Kupietz33146542021-06-18 12:32:38 +020021 error_y="error_y", error_y_minus="error_y_minus")
Marc Kupietz12a9fe82020-06-16 14:27:57 +020022fig.show()