chore(script): Fix type error

This commit is contained in:
Marty Oehme 2024-07-29 12:50:18 +02:00
parent bd25353fa1
commit 2b986b46a6
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A

View file

@ -593,6 +593,7 @@ the overall output volume strongly increased during this period.
```{python} ```{python}
#| label: fig-publications-per-year #| label: fig-publications-per-year
#| fig-cap: Publications per year #| fig-cap: Publications per year
from typing import cast
df_study_years = ( df_study_years = (
df.groupby(["author", "year", "title"]) df.groupby(["author", "year", "title"])
@ -602,6 +603,8 @@ df_study_years = (
["year"].value_counts() ["year"].value_counts()
.sort_index() .sort_index()
) )
df_study_years = cast(pd.DataFrame, df_study_years) # fix potential type errors
# use order to ensure all years are displayed, even ones without values # use order to ensure all years are displayed, even ones without values
years_range = list(range(df_study_years.index.min(), df_study_years.index.max()+1)) years_range = list(range(df_study_years.index.min(), df_study_years.index.max()+1))
ax = sns.barplot(df_study_years, order=years_range) ax = sns.barplot(df_study_years, order=years_range)