Marc Kupietz | 12a9fe8 | 2020-06-16 14:27:57 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Marc Kupietz | 6d53974 | 2020-06-25 18:33:20 +0200 | [diff] [blame] | 2 | from KorAPClient import KorAPClient, KorAPConnection |
Marc Kupietz | 12a9fe8 | 2020-06-16 14:27:57 +0200 | [diff] [blame] | 3 | import plotly.express as px |
Marc Kupietz | 12a9fe8 | 2020-06-16 14:27:57 +0200 | [diff] [blame] | 4 | |
| 5 | QUERY = "Hello World" |
| 6 | YEARS = range(2010, 2019) |
| 7 | COUNTRIES = ["DE", "CH"] |
| 8 | |
Marc Kupietz | 6d53974 | 2020-06-25 18:33:20 +0200 | [diff] [blame] | 9 | kcon = KorAPConnection(verbose=True) |
Marc Kupietz | 12a9fe8 | 2020-06-16 14:27:57 +0200 | [diff] [blame] | 10 | |
Marc Kupietz | 7fdb415 | 2021-06-18 12:39:17 +0200 | [diff] [blame^] | 11 | vcs = [f"textType=/Zeit.*/ & pubPlaceKey={c} & pubDate in {y}" for c in COUNTRIES for y in YEARS] |
Marc Kupietz | 6d53974 | 2020-06-25 18:33:20 +0200 | [diff] [blame] | 12 | df = KorAPClient.ipm(kcon.frequencyQuery(QUERY, vcs)) |
| 13 | print(df) |
| 14 | |
Marc Kupietz | 12a9fe8 | 2020-06-16 14:27:57 +0200 | [diff] [blame] | 15 | df['Year'] = [y for c in COUNTRIES for y in YEARS] |
| 16 | df['Country'] = [c for c in COUNTRIES for y in YEARS] |
Marc Kupietz | 3314654 | 2021-06-18 12:32:38 +0200 | [diff] [blame] | 17 | df['error_y'] = df["conf.high"] - df["ipm"] |
| 18 | df['error_y_minus'] = df["ipm"] - df["conf.low"] |
Marc Kupietz | 12a9fe8 | 2020-06-16 14:27:57 +0200 | [diff] [blame] | 19 | |
| 20 | fig = px.line(df, title=QUERY, x="Year", y="ipm", color="Country", |
Marc Kupietz | 3314654 | 2021-06-18 12:32:38 +0200 | [diff] [blame] | 21 | error_y="error_y", error_y_minus="error_y_minus") |
Marc Kupietz | 12a9fe8 | 2020-06-16 14:27:57 +0200 | [diff] [blame] | 22 | fig.show() |