mirror of
https://github.com/koodiklinikka/palkkakysely.git
synced 2026-02-04 03:48:03 +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")
|
||||
|
||||
|
||||
def get_categorical_stats_plot(df, *, category, na_as_category=None):
|
||||
df = get_categorical_stats(
|
||||
df, category, "Vuositulot", na_as_category=na_as_category
|
||||
)
|
||||
def get_categorical_stats_plot(df, *, category, value, na_as_category=None):
|
||||
df = get_categorical_stats(df, category, value, na_as_category=na_as_category)
|
||||
df.reset_index(inplace=True)
|
||||
df[category] = df[category].astype("category")
|
||||
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)
|
||||
plot.vbar(
|
||||
|
||||
@@ -24,7 +24,7 @@ def plot_this(fn):
|
||||
@plot_this
|
||||
def plot_kokemus_tulot(df: DataFrame):
|
||||
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.xaxis.axis_label = "Työkokemus (v)"
|
||||
set_yaxis_cash(plot)
|
||||
@@ -35,13 +35,15 @@ def plot_kokemus_tulot(df: DataFrame):
|
||||
|
||||
|
||||
@plot_this
|
||||
def plot_ika_tulot(df: DataFrame):
|
||||
return get_categorical_stats_plot(df, category="Ikä")
|
||||
def plot_ika_vuositulot(df: DataFrame):
|
||||
return get_categorical_stats_plot(df, category="Ikä", value="Vuositulot")
|
||||
|
||||
|
||||
@plot_this
|
||||
def plot_sukupuoli_tulot(df: DataFrame):
|
||||
return get_categorical_stats_plot(df, category="Sukupuoli", na_as_category="EOS")
|
||||
def plot_sukupuoli_vuositulot(df: DataFrame):
|
||||
return get_categorical_stats_plot(
|
||||
df, category="Sukupuoli", value="Vuositulot", na_as_category="EOS"
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
Reference in New Issue
Block a user