Upload folder using huggingface_hub
Browse files- .claude/settings.local.json +11 -0
- .gitattributes +4 -0
- CabbageEDA.py +69 -0
- CabbageIntake.xlsx +3 -0
- CabbageIntake2.xlsx +0 -0
- CabbageIntake_merged.xlsx +3 -0
- CabbagePrice.xlsx +3 -0
- CabbagePrice2.xlsx +0 -0
- CabbagePrice_merged.xlsx +3 -0
- CabbageRetail.py +49 -0
- merge_data.py +54 -0
- store/cabbage_retail.csv +0 -0
- store/cabbage_separated.csv +0 -0
.claude/settings.local.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"permissions": {
|
| 3 |
+
"allow": [
|
| 4 |
+
"Bash(python -c:*)",
|
| 5 |
+
"Bash(python merge_data.py:*)",
|
| 6 |
+
"Bash(python:*)"
|
| 7 |
+
],
|
| 8 |
+
"deny": [],
|
| 9 |
+
"ask": []
|
| 10 |
+
}
|
| 11 |
+
}
|
.gitattributes
CHANGED
|
@@ -57,3 +57,7 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 57 |
# Video files - compressed
|
| 58 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 59 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
# Video files - compressed
|
| 58 |
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 59 |
*.webm filter=lfs diff=lfs merge=lfs -text
|
| 60 |
+
CabbageIntake.xlsx filter=lfs diff=lfs merge=lfs -text
|
| 61 |
+
CabbageIntake_merged.xlsx filter=lfs diff=lfs merge=lfs -text
|
| 62 |
+
CabbagePrice.xlsx filter=lfs diff=lfs merge=lfs -text
|
| 63 |
+
CabbagePrice_merged.xlsx filter=lfs diff=lfs merge=lfs -text
|
CabbageEDA.py
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import pandas as pd
|
| 3 |
+
|
| 4 |
+
# 파일 경로
|
| 5 |
+
cabbage_path = 'CabbagePrice_merged.xlsx'
|
| 6 |
+
intake_path = 'CabbageIntake_merged.xlsx'
|
| 7 |
+
|
| 8 |
+
# 시트 불러오기
|
| 9 |
+
cabbage_df = pd.read_excel(cabbage_path, sheet_name=0)
|
| 10 |
+
intake_df = pd.read_excel(intake_path, sheet_name=0)
|
| 11 |
+
|
| 12 |
+
# 특, 상 필터
|
| 13 |
+
grade_ratio = {
|
| 14 |
+
'특': ('SPECIAL', 0.05),
|
| 15 |
+
'상': ('HIGH', 0.35),
|
| 16 |
+
}
|
| 17 |
+
filtered = cabbage_df[cabbage_df['등급명'].isin(grade_ratio)].copy()
|
| 18 |
+
|
| 19 |
+
# 평균가격 정수형 변환 (컬럼명 체크)
|
| 20 |
+
if '평균가격' in filtered.columns:
|
| 21 |
+
price_col = '평균가격'
|
| 22 |
+
elif '당일' in filtered.columns:
|
| 23 |
+
price_col = '당일'
|
| 24 |
+
else:
|
| 25 |
+
raise ValueError("가격 정보를 찾을 수 없습니다.")
|
| 26 |
+
|
| 27 |
+
filtered['avg_price'] = filtered[price_col].astype(str).str.replace(',', '').astype(int)
|
| 28 |
+
|
| 29 |
+
# 0원인 데이터 제거
|
| 30 |
+
filtered = filtered[filtered['avg_price'] != 0]
|
| 31 |
+
|
| 32 |
+
# 레이블, 비율 컬럼 추가
|
| 33 |
+
filtered['rate'] = filtered['등급명'].map(lambda x: grade_ratio[x][0])
|
| 34 |
+
filtered['비율'] = filtered['등급명'].map(lambda x: grade_ratio[x][1])
|
| 35 |
+
|
| 36 |
+
# 반입량 합치기
|
| 37 |
+
intake_df = intake_df[['DATE', '총반입량']].copy()
|
| 38 |
+
intake_df.rename(columns={'총반입량': 'total_intake'}, inplace=True)
|
| 39 |
+
|
| 40 |
+
merged = pd.merge(filtered, intake_df, on='DATE', how='inner')
|
| 41 |
+
|
| 42 |
+
# intake 계산
|
| 43 |
+
merged['intake'] = (merged['total_intake'] * merged['비율']).round().astype(int)
|
| 44 |
+
|
| 45 |
+
# 날짜 분해
|
| 46 |
+
merged[['year', 'month', 'day']] = merged['DATE'].astype(str).str.split('-', expand=True).astype(int)
|
| 47 |
+
|
| 48 |
+
# gap 계산 (같은 등급 기준 전날과의 가격 차이)
|
| 49 |
+
merged.sort_values(['rate', 'DATE'], inplace=True)
|
| 50 |
+
merged['gap'] = merged.groupby('rate')['avg_price'].diff().fillna(0).astype(int)
|
| 51 |
+
|
| 52 |
+
# 최종 정리
|
| 53 |
+
final_df = merged[['year', 'month', 'day', 'intake', 'avg_price', 'gap', 'rate']]
|
| 54 |
+
final_df = final_df.sort_values(['year', 'month', 'day', 'rate'])
|
| 55 |
+
|
| 56 |
+
final_df.sort_values(by=['rate', 'year', 'month', 'day'], inplace=True)
|
| 57 |
+
|
| 58 |
+
# 저장
|
| 59 |
+
os.makedirs('store', exist_ok=True)
|
| 60 |
+
output_path = 'store/cabbage_separated.csv'
|
| 61 |
+
final_df.to_csv(output_path, index=False)
|
| 62 |
+
|
| 63 |
+
print(f"총 {len(final_df)}행 처리 완료")
|
| 64 |
+
print(f"날짜 범위: {final_df['year'].min()}-{final_df['month'].min()}-{final_df['day'].min()} ~ {final_df['year'].max()}-{final_df['month'].max()}-{final_df['day'].max()}")
|
| 65 |
+
print(f"\n등급별 데이터 수:")
|
| 66 |
+
print(final_df['rate'].value_counts())
|
| 67 |
+
print(f"\n처음 10행:")
|
| 68 |
+
print(final_df.head(10))
|
| 69 |
+
print(f"\n저장 완료: {output_path}")
|
CabbageIntake.xlsx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3891a9b25ebf208dc58139c2ada03bc03f009a4f11227b1092a8ef28ab73e862
|
| 3 |
+
size 145748
|
CabbageIntake2.xlsx
ADDED
|
Binary file (13.4 kB). View file
|
|
|
CabbageIntake_merged.xlsx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a3144092a04d559f32dcaeecaf18f40d26595f06cb3c7575bcad8582d7a25942
|
| 3 |
+
size 152012
|
CabbagePrice.xlsx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:af61ef063949454764939db6279d82e5af90726f600ace3d561d272738955199
|
| 3 |
+
size 213229
|
CabbagePrice2.xlsx
ADDED
|
Binary file (16.3 kB). View file
|
|
|
CabbagePrice_merged.xlsx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4941aaac3e19b44ac4cc384e0cc03302a483e392e74106b2b2925d9eac1d469d
|
| 3 |
+
size 230453
|
CabbageRetail.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
# CabbagePrice_merged.xlsx 파일 읽기
|
| 5 |
+
retail_path = 'CabbagePrice_merged.xlsx'
|
| 6 |
+
retail_df = pd.read_excel(retail_path)
|
| 7 |
+
|
| 8 |
+
# '평균가격' 컬럼이 있는지 확인하고, 없으면 '당일' 컬럼 사용
|
| 9 |
+
if '평균가격' in retail_df.columns:
|
| 10 |
+
price_col = '평균가격'
|
| 11 |
+
elif '당일' in retail_df.columns:
|
| 12 |
+
price_col = '당일'
|
| 13 |
+
else:
|
| 14 |
+
raise ValueError("가격 정보를 찾을 수 없습니다.")
|
| 15 |
+
|
| 16 |
+
# ',' 제거하고 평균가격 숫자로 변환
|
| 17 |
+
retail_df['avg_price'] = (
|
| 18 |
+
retail_df[price_col]
|
| 19 |
+
.astype(str)
|
| 20 |
+
.str.replace(',', '')
|
| 21 |
+
.astype(float) # 먼저 float으로 변환
|
| 22 |
+
.round() # 반올림
|
| 23 |
+
.astype(int) # 최종 정수형 변환
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
# 평균가격이 0이 아닌 행만 필터링
|
| 27 |
+
retail_df = retail_df[retail_df['avg_price'] != 0].copy()
|
| 28 |
+
|
| 29 |
+
# 날짜 분해
|
| 30 |
+
retail_df[['year', 'month', 'day']] = retail_df['DATE'].astype(str).str.split('-', expand=True).astype(int)
|
| 31 |
+
|
| 32 |
+
# 가격 차이(gap) 계산
|
| 33 |
+
retail_df.sort_values('DATE', inplace=True)
|
| 34 |
+
retail_df['gap'] = retail_df['avg_price'].diff().fillna(0).astype(int)
|
| 35 |
+
|
| 36 |
+
# 최종 열 선택 및 정렬
|
| 37 |
+
final_retail_df = retail_df[['year', 'month', 'day', 'avg_price', 'gap']]
|
| 38 |
+
final_retail_df = final_retail_df.sort_values(['year', 'month', 'day'])
|
| 39 |
+
|
| 40 |
+
# 저장 (store 폴더 생성)
|
| 41 |
+
os.makedirs('store', exist_ok=True)
|
| 42 |
+
output_path = 'store/cabbage_retail.csv'
|
| 43 |
+
final_retail_df.to_csv(output_path, index=False)
|
| 44 |
+
|
| 45 |
+
print(f"총 {len(final_retail_df)}행 처리 완료")
|
| 46 |
+
print(f"날짜 범위: {final_retail_df['year'].min()}-{final_retail_df['month'].min()}-{final_retail_df['day'].min()} ~ {final_retail_df['year'].max()}-{final_retail_df['month'].max()}-{final_retail_df['day'].max()}")
|
| 47 |
+
print(f"\n처음 5행:")
|
| 48 |
+
print(final_retail_df.head())
|
| 49 |
+
print(f"\n저장 완료: {output_path}")
|
merge_data.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
|
| 3 |
+
# CabbagePrice 데이터 합치기
|
| 4 |
+
print("=== CabbagePrice 데이터 합치기 ===")
|
| 5 |
+
price1_df = pd.read_excel('CabbagePrice.xlsx', sheet_name=0)
|
| 6 |
+
price2_df = pd.read_excel('CabbagePrice2.xlsx', sheet_name=0)
|
| 7 |
+
|
| 8 |
+
print(f"CabbagePrice.xlsx: {len(price1_df)}행")
|
| 9 |
+
print(f"CabbagePrice2.xlsx: {len(price2_df)}행")
|
| 10 |
+
|
| 11 |
+
# 두 데이터 합치기
|
| 12 |
+
merged_price_df = pd.concat([price1_df, price2_df], ignore_index=True)
|
| 13 |
+
|
| 14 |
+
# DATE 기준으로 정렬
|
| 15 |
+
merged_price_df = merged_price_df.sort_values('DATE').reset_index(drop=True)
|
| 16 |
+
|
| 17 |
+
# 중복 제거 (DATE, 등급명 기준)
|
| 18 |
+
merged_price_df = merged_price_df.drop_duplicates(subset=['DATE', '등급명'], keep='last').reset_index(drop=True)
|
| 19 |
+
|
| 20 |
+
print(f"합친 후: {len(merged_price_df)}행")
|
| 21 |
+
print(f"날짜 범위: {merged_price_df['DATE'].min()} ~ {merged_price_df['DATE'].max()}")
|
| 22 |
+
|
| 23 |
+
# 저장
|
| 24 |
+
merged_price_df.to_excel('CabbagePrice_merged.xlsx', index=False)
|
| 25 |
+
print("저장 완료: CabbagePrice_merged.xlsx\n")
|
| 26 |
+
|
| 27 |
+
# CabbageIntake 데이터 합치기
|
| 28 |
+
print("=== CabbageIntake 데이터 합치기 ===")
|
| 29 |
+
intake1_df = pd.read_excel('CabbageIntake.xlsx', sheet_name=0)
|
| 30 |
+
intake2_df = pd.read_excel('CabbageIntake2.xlsx', sheet_name=0)
|
| 31 |
+
|
| 32 |
+
print(f"CabbageIntake.xlsx: {len(intake1_df)}행")
|
| 33 |
+
print(f"CabbageIntake2.xlsx: {len(intake2_df)}행")
|
| 34 |
+
|
| 35 |
+
# 두 데이터 합치기
|
| 36 |
+
merged_intake_df = pd.concat([intake1_df, intake2_df], ignore_index=True)
|
| 37 |
+
|
| 38 |
+
# DATE 기준으로 정렬
|
| 39 |
+
merged_intake_df = merged_intake_df.sort_values('DATE').reset_index(drop=True)
|
| 40 |
+
|
| 41 |
+
# 중복 제거 (DATE 기준)
|
| 42 |
+
merged_intake_df = merged_intake_df.drop_duplicates(subset=['DATE'], keep='last').reset_index(drop=True)
|
| 43 |
+
|
| 44 |
+
print(f"합친 후: {len(merged_intake_df)}행")
|
| 45 |
+
print(f"날짜 범위: {merged_intake_df['DATE'].min()} ~ {merged_intake_df['DATE'].max()}")
|
| 46 |
+
|
| 47 |
+
# 저장
|
| 48 |
+
merged_intake_df.to_excel('CabbageIntake_merged.xlsx', index=False)
|
| 49 |
+
print("저장 완료: CabbageIntake_merged.xlsx")
|
| 50 |
+
|
| 51 |
+
print("\n=== 완료 ===")
|
| 52 |
+
print("생성된 파일:")
|
| 53 |
+
print(" - CabbagePrice_merged.xlsx")
|
| 54 |
+
print(" - CabbageIntake_merged.xlsx")
|
store/cabbage_retail.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
store/cabbage_separated.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|