Sparta/Normal

[250910] 스파르타코딩 본캠프 27일차

junecho 2025. 9. 10. 23:35
stype_year_p = stype.groupby(["계약년도"])["물건금액(만원)"].median()
gangseo_year = gangseo_df.groupby(["계약년도"])["물건금액(만원)"].median()
seongdong_df = df[(df["자치구명"] == "성동구") & (df["건물면적(㎡)"] <= 60)].copy()
seongdong_year = seongdong_df.groupby(["계약년도"])["물건금액(만원)"].median()
# 한번만 실행
stype_year_price = stype_year_p.sort_values(ascending=False).reset_index()
gangseo_year_price = gangseo_year.sort_values(ascending=False).reset_index()
seongdong_year_price = seongdong_year.sort_values(ascending=False).reset_index()
plt.figure(figsize=(10,6))

sns.lineplot(x="계약년도", y="물건금액(만원)", data=seongdong_year_price, marker = "o", color=max_fontcolor, label="성동구")
sns.lineplot(x="계약년도", y="물건금액(만원)", data=stype_year_price, marker = "o", color=std_fontcolor, label="전체구")
sns.lineplot(x="계약년도", y="물건금액(만원)", data=gangseo_year_price, marker = "o", color=min_fontcolor, label="강서구")

from matplotlib.ticker import FuncFormatter
formatter = FuncFormatter(lambda x, pos: f'{x:,.0f}')
plt.gca().yaxis.set_major_formatter(formatter)

plt.grid(axis="y", linestyle="--",alpha=0.5)
plt.title("소형 평수 연도별 중위 금액 추세선", fontproperties=prop, fontsize=20)
plt.xlabel("", fontproperties=prop)
plt.xticks(fontproperties=prop, fontsize=12)
plt.yticks(fontproperties=prop)
plt.ylabel("( 만원 )", fontproperties=prop)
plt.legend(prop=prop)
plt.show()

 

 

 

이미 죽어있는 자의 블로그 입니다