mirror of
https://github.com/koodiklinikka/palkkakysely.git
synced 2026-03-05 19:00:16 +00:00
Allow for plotting something else than vuositulot as categorical
This commit is contained in:
@@ -18,14 +18,12 @@ def set_yaxis_cash(plot):
|
|||||||
plot.yaxis[0].formatter = bm.NumeralTickFormatter(format="€0")
|
plot.yaxis[0].formatter = bm.NumeralTickFormatter(format="€0")
|
||||||
|
|
||||||
|
|
||||||
def get_categorical_stats_plot(df, *, category, na_as_category=None):
|
def get_categorical_stats_plot(df, *, category, value, na_as_category=None):
|
||||||
df = get_categorical_stats(
|
df = get_categorical_stats(df, category, value, na_as_category=na_as_category)
|
||||||
df, category, "Vuositulot", na_as_category=na_as_category
|
|
||||||
)
|
|
||||||
df.reset_index(inplace=True)
|
df.reset_index(inplace=True)
|
||||||
df[category] = df[category].astype("category")
|
df[category] = df[category].astype("category")
|
||||||
plot = bp.figure(
|
plot = bp.figure(
|
||||||
title=f"{category}/tulot", x_range=list(df[category].cat.categories)
|
title=f"{category}/{value}", x_range=list(df[category].cat.categories)
|
||||||
)
|
)
|
||||||
set_yaxis_cash(plot)
|
set_yaxis_cash(plot)
|
||||||
plot.vbar(
|
plot.vbar(
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ def plot_this(fn):
|
|||||||
@plot_this
|
@plot_this
|
||||||
def plot_kokemus_tulot(df: DataFrame):
|
def plot_kokemus_tulot(df: DataFrame):
|
||||||
source = bm.ColumnDataSource(df)
|
source = bm.ColumnDataSource(df)
|
||||||
plot = bp.figure(title="Kokemus/Tulot")
|
plot = bp.figure(title="Kokemus/Vuositulot")
|
||||||
plot.add_tools(get_df_hover_tool(df))
|
plot.add_tools(get_df_hover_tool(df))
|
||||||
plot.xaxis.axis_label = "Työkokemus (v)"
|
plot.xaxis.axis_label = "Työkokemus (v)"
|
||||||
set_yaxis_cash(plot)
|
set_yaxis_cash(plot)
|
||||||
@@ -35,13 +35,15 @@ def plot_kokemus_tulot(df: DataFrame):
|
|||||||
|
|
||||||
|
|
||||||
@plot_this
|
@plot_this
|
||||||
def plot_ika_tulot(df: DataFrame):
|
def plot_ika_vuositulot(df: DataFrame):
|
||||||
return get_categorical_stats_plot(df, category="Ikä")
|
return get_categorical_stats_plot(df, category="Ikä", value="Vuositulot")
|
||||||
|
|
||||||
|
|
||||||
@plot_this
|
@plot_this
|
||||||
def plot_sukupuoli_tulot(df: DataFrame):
|
def plot_sukupuoli_vuositulot(df: DataFrame):
|
||||||
return get_categorical_stats_plot(df, category="Sukupuoli", na_as_category="EOS")
|
return get_categorical_stats_plot(
|
||||||
|
df, category="Sukupuoli", value="Vuositulot", na_as_category="EOS"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
Reference in New Issue
Block a user