import pandas as pd
import matplotlib.pyplot as plt
plt.rcParams['axes.unicode_minus'] = False
plt.rcParams['font.family'] = 'Malgun Gothic'
df_delivery = pd.read_csv('./배달_사용_통계.csv', encoding='cp949')
df_delivery.columns = df_delivery.columns.str.strip()
df_covid = pd.read_csv('./코로나_확진자_수_통계.csv', encoding='utf-8')
df_covid.columns = df_covid.columns.str.strip()
df = pd.merge(df_delivery, df_covid, on='연도', how='inner')
print(df.keys())
df['연도'] = pd.to_numeric(df['연도'], errors='coerce') # 연도 열이 제대로 숫자로 되어 있는지 확인
df['배달앱'] = pd.to_numeric(df['배달앱'], errors='coerce') # 배달앱 이용량
df['배달대행'] = pd.to_numeric(df['배달대행'], errors='coerce') # 배달대행 이용량
df['확진자'] = pd.to_numeric(df['확진자'], errors='coerce')
df['사망자'] = pd.to_numeric(df['사망자'], errors='coerce')
df = df.dropna(subset=['연도', '배달앱', '배달대행'])
plt.figure(figsize=(10, 5))
plt.plot(df['연도'], df['배달앱'], marker='o', linestyle='-', color='blue', label='배달앱 이용량')
plt.plot(df['연도'], df['배달대행'], marker='o', linestyle='-', color='red', label='배달대행 이용량')
plt.plot(df['연도'], df['확진자'], marker='o', linestyle='-', color='green', label='코로나 확진자 수')
plt.plot(df['연도'], df['사망자'], marker='o', linestyle='-', color='purple', label='코로나 사망자 수')
plt.xlabel('연도')
plt.ylabel('이용량% 및 확진자% & 사망률')
plt.title('연도별 배달앱과 배달대행 이용량')
plt.xticks(rotation=45)
plt.grid()
plt.legend()
plt.show()
# plt.figure(figsize=(10, 5))
#
# plt.plot(df['연도'], df['배달앱'], marker='o', linestyle='-', color='blue', label='배달앱 이용량')
#
#
# plt.xlabel('연도')
#
# plt.ylabel('배달앱 이용량')
#
# plt.title('연도별 배달앱 이용량')
#
# plt.xticks(rotation=45)
#
# plt.grid()
#
# plt.legend()
#
# plt.show()
#
#
# print("✅ 연도별 배달앱 그래프 출력 완료!")
#
#
#
# plt.figure(figsize=(10, 5))
#
# plt.plot(df['연도'], df['배달대행'], marker='o', linestyle='-', color='red', label='배달대행 이용량')
#
#
# plt.xlabel('연도')
#
# plt.ylabel('배달대행 이용량')
#
# plt.title('연도별 배달대행 이용량')
#
# plt.xticks(rotation=45)
#
# plt.grid()
#
# plt.legend()
#
# plt.show()
#
#
# print("✅ 연도별 배달대행 그래프 출력 완료!")




file:/C:/Users/SooahCodeLab/PycharmProjects/pythonProject8/배달_사용_통계.csv