From 1bc7201c9de4fb07643c0aef8bfee1b84d56de3b Mon Sep 17 00:00:00 2001 From: Re-st Date: Fri, 24 Nov 2023 16:52:52 +0900 Subject: [PATCH] =?UTF-8?q?[analysis]=20histogram=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EB=AC=B8=EC=A0=9C=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- analysis/age/hist_groups.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/analysis/age/hist_groups.py b/analysis/age/hist_groups.py index 8fa9e92..fdc0b92 100644 --- a/analysis/age/hist_groups.py +++ b/analysis/age/hist_groups.py @@ -279,16 +279,12 @@ def cluster(df, year, n_clst, method, cluster_by, outdir, font_name, folder_name # 히스토그램을 그립니다. histdata = [ { - "minAge": age, - "maxAge": age + 1, - "count": count, - "ageGroup": age_group, + "minAge": int(age), + "maxAge": int(age) + 1, + "count": df_clst[df_clst["age"] == age].shape[0], + "ageGroup": int(df_clst.loc[df_clst["age"] == age].iloc[0]["cluster_label"]) } - for age, count, age_group in zip( - range(df_clst["age"].min(), df_clst["age"].max() + 1), - df_clst.groupby("age").size(), - df_clst.groupby("age")["cluster_label"].first(), - ) + for age in df_clst["age"].unique() ] statdata = None if method == "equal":