Skip to content

Commit

Permalink
add 2023 analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesFriedrich committed Dec 30, 2023
1 parent 1cedb75 commit 9182f64
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 28 deletions.
10 changes: 4 additions & 6 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ output: rmarkdown::github_document

<!-- README.md is generated from README.Rmd. Please edit that file -->

# API for the lotto numbers of the german lottery (1955-2021)
# API for the lotto numbers of the german lottery (1955-2023)

```{r setup, include=FALSE, echo = FALSE}
knitr::opts_chunk$set(collapse = TRUE,
Expand Down Expand Up @@ -86,18 +86,17 @@ ggplot(superzahl, aes(value, count, fill = Day)) +
labs(x = "Zusatzzahl", title = "Zusatzzahl since 2001")
```

What were the numbers most chosen in 2021?
What were the numbers most chosen in 2023?

```{r}
data %>%
filter(variable == "Lottozahl") %>%
mutate(date = dmy(date),
year = year(date)) %>%
filter(year == 2021) %>%
filter(year == 2023) %>%
group_by(value) %>%
summarise(count = n()) %>%
arrange(desc(count)) %>%
top_n(5)
slice_max(count, n = 5)
```


Expand All @@ -113,6 +112,5 @@ data = pd.read_json("https://johannesfriedrich.github.io/LottoNumberArchive/Lott
res = data[data.variable == "Lottozahl"].groupby("value")["value"].count().sort_values(ascending = False)
print(res.head(5))
```

48 changes: 26 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,16 @@ lottonumbers_count %>%
arrange(desc(count)) %>%
top_n(5)
## Selecting by count
## # A tibble: 5 × 2
## # A tibble: 7 × 2
## value count
## <int> <int>
## 1 6 633
## 2 49 621
## 3 32 608
## 4 11 605
## 5 31 600
## 1 6 646
## 2 49 632
## 3 32 620
## 4 31 615
## 5 22 614
## 6 26 614
## 7 33 614
```

Now we want to summarise all numbers from 1-49 and their appearance.
Expand Down Expand Up @@ -97,27 +99,28 @@ ggplot(superzahl, aes(value, count, fill = Day)) +

<img src="README_figs/README-unnamed-chunk-5-1.png" width="672" style="display: block; margin: auto;" />

What were the numbers most chosen in 2022?
What were the numbers most chosen in 2023?

``` r
data %>%
filter(variable == "Lottozahl") %>%
mutate(date = dmy(date),
year = year(date)) %>%
filter(year == 2022) %>%
filter(year == 2023) %>%
group_by(value) %>%
summarise(count = n()) %>%
arrange(desc(count)) %>%
top_n(5)
## Selecting by count
## # A tibble: 5 × 2
slice_max(count, n = 5)
## # A tibble: 8 × 2
## value count
## <int> <int>
## 1 49 21
## 2 1 20
## 3 16 20
## 4 2 18
## 5 32 18
## 1 19 19
## 2 22 18
## 3 33 18
## 4 25 17
## 5 23 16
## 6 28 16
## 7 42 16
## 8 43 16
```

### Python
Expand All @@ -130,15 +133,16 @@ executed.
import pandas as pd

data = pd.read_json("https://johannesfriedrich.github.io/LottoNumberArchive/Lottonumbers_tidy_complete.json")
## <string>:2: UserWarning: Parsing dates in DD/MM/YYYY format when dayfirst=False (the default) was specified. This may lead to inconsistently parsed dates! Specify a format to ensure consistent parsing.

res = data[data.variable == "Lottozahl"].groupby("value")["value"].count().sort_values(ascending = False)

print(res.head(5))
## value
## 6 633
## 49 621
## 32 608
## 11 605
## 31 600
## 6 646
## 49 632
## 32 620
## 31 615
## 33 614
## Name: value, dtype: int64
```
Binary file modified README_figs/README-unnamed-chunk-3-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified README_figs/README-unnamed-chunk-5-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9182f64

Please sign in to comment.