top of page

소스 코드 제출

공개·회원 69명

20250510

'''

How to make a Portfolio

0. 주제를 선정하는데, 가정을 고려한다 "ㅇㅇㅇ하면 ㅇㅇㅇ이니 ㅇㅇㅇ할 것 이다"

1. 데이터를 가져온다(csv:txt)

2. 데이터를 로드한다(파이썬)

3. 데이터를 그래프화 시켜본다(각종 도구 및 조합을 이용해)

4. 3번의 동작을 확장시켜서 이야깃거리를 만든다

5. 정리하고 완성한다.

`



'''


# import pandas as pd

# import cv2

# import numpy as np

#

# # CSV 파일 불러오기

# df = pd.read_csv("C:\\Users\\SooahCodeLab\\Downloads\\deliver change.csv", encoding='cp949')

# print(df.head()) # 데이터 확인

#

# # 이미지 설정

# width, height = 600, 400

# img = np.zeros((height, width, 3), dtype=np.uint8) # 검은색 배경 생성

#

# # 데이터 정규화

# data_x = np.linspace(50, width - 50, len(df)) # X축을 균등 분배

# data_y = np.interp(df["값"], (df["값"].min(), df["값"].max()), (height - 50, 50)) # 값 정규화

#

# # 그래프 그리기

# for i in range(len(df) - 1):

# cv2.line(img, (int(data_x[i]), int(data_y[i])), (int(data_x[i + 1]), int(data_y[i + 1])), (255, 0, 0), 2)

#

# # 이미지 출력

# cv2.imshow("Line Chart", img)

# cv2.waitKey(0)

# cv2.destroyAllWindows()

# # 이미지 설정

# img = np.zeros((height, width, 3), dtype=np.uint8) # 검은색 배경 생성

# bar_width = int((width - 100) / len(df)) # 바 너비 설정

#

# # 바 차트 그리기

# for i, value in enumerate(df["값"]):

# x = 50 + i * bar_width

# y = int(np.interp(value, (df["값"].min(), df["값"].max()), (height - 50, 50))) # 값 정규화

# cv2.rectangle(img, (x, y), (x + bar_width - 5, height - 50), (0, 255, 0), -1) # 바 그리기

#

# # 이미지 출력

# cv2.imshow("Bar Chart", img)

# cv2.waitKey(0)

# cv2.destroyAllWindows()

import pandas as pd

import matplotlib.pyplot as plt


plt.rcParams['axes.unicode_minus'] = False

plt.rcParams['font.family'] = 'Malgun Gothic'


# ✅ CSV 파일 불러오기

df = pd.read_csv('./배달_사용_통계.csv', encoding='cp949')


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 = df.dropna(subset=['연도', '배달앱', '배달대행'])


# ✅ 첫 번째 그래프: 배달앱 이용량

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("✅ 연도별 배달대행 그래프 출력 완료!")



#

# import pandas as pd

# import matplotlib.pyplot as plt

#

# df = pd.read_csv('./배달_사용_통계.csv', encoding='cp949', header=1)

# df.columns = ['날짜', '주문량', '배달 주문량 변화', '기타1', '기타2', '기타3', '기타4', '기타5']

#

# print(df.info())

# print(df.head())

# print(df.describe())

# print("🔹 CSV 파일 컬럼 목록:", df.columns)

#

# df = df.dropna(subset=['날짜', '주문량'])

#

#

# if '날짜' in df.columns:

# df['날짜'] = pd.to_datetime(df['날짜'])

# elif 'Date' in df.columns:

# df['Date'] = pd.to_datetime(df['Date'])

# df.rename(columns={'Date': '날짜'}, inplace=True) # 열 이름 변경

#

# # 결측값 처리

# df.fillna(df.mean(numeric_only=True), inplace=True)

#

# # ✅ 그래프 그리기

# plt.figure(figsize=(10, 5))

# plt.plot(df['날짜'], df['주문량'], marker='o', linestyle='-', color='blue')

#

# # 그래프 설정

# plt.xlabel('날짜')

# plt.ylabel('주문량')

# plt.title('배달 주문량 변화')

# plt.xticks(rotation=45)

# plt.grid()

# plt.show()

#

# print("✅ 그래프 출력 완료!")


#

# print("\n🔹 컬럼 목록:", df.columns)

# print("\n🔹 첫 5개 행:\n", df.head())

#

# if '날짜' in df.columns:

# df['날짜'] = pd.to_datetime(df['날짜'])

# elif 'Date' in df.columns:

# df['Date'] = pd.to_datetime(df['Date'])

# df.rename(columns={'Date': '날짜'}, inplace=True)

#

#

# df.fillna(df.mean(), inplace=True)

#

#

# plt.figure(figsize=(10, 5))

# plt.plot(df['날짜'], df['주문량'], marker='o', linestyle='-', color='blue')

# plt.xlabel('날짜')

# plt.ylabel('주문량')

# plt.title('배달 주문량 변화')

# plt.xticks(rotation=45)

# plt.grid()

# plt.show()

#

# print("✅ CSV 데이터 분석 및 그래프 출력 완료!")

#



5회 조회
주소 : 경기도 용인시 광교중앙로 302 블루 스퀘어 602호
연락처 : 031) 216 - 1546 ,     031) 215 - 1546
사업자등록번호 : 465-92-00916
​학원 등록 제 4603호
bottom of page