Spaces:
Sleeping
Sleeping
Yoon-gu Hwang commited on
Commit ยท
9c143e2
1
Parent(s): b2b4159
update
Browse files
app.py
CHANGED
|
@@ -1,60 +1,17 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import numpy as np
|
| 3 |
import pandas as pd
|
|
|
|
| 4 |
from datetime import datetime, timedelta
|
| 5 |
|
| 6 |
-
def
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
# ์นด๋ ์ข
๋ฅ
|
| 15 |
-
cards = ['์ ํ์นด๋', '์ผ์ฑ์นด๋', 'ํ๋์นด๋', 'KB๊ตญ๋ฏผ์นด๋', '์ฐ๋ฆฌ์นด๋']
|
| 16 |
-
|
| 17 |
-
# ๊ฐ๋งน์ ์ข
๋ฅ
|
| 18 |
-
merchants = ['์คํ๋ฒ
์ค', 'GS25', '์ฟ ํก', '๋ค์ด๋ฒํ์ด', '์นด์นด์คํ์ด',
|
| 19 |
-
'์ด๋งํธ', '์ฌ๋ฆฌ๋ธ์', 'CGV', '๋ฐฐ๋ฌ์๋ฏผ์กฑ', '์นดํ๋ฒ ๋ค',
|
| 20 |
-
'Apple', '11๋ฒ๊ฐ', '๋ฌด์ ์ฌ', '๋ค์ด์', '๋งฅ๋๋ ๋']
|
| 21 |
-
|
| 22 |
-
# ํ ๋ถ ์ต์
|
| 23 |
-
installments = ['์ผ์๋ถ', '2๊ฐ์', '3๊ฐ์', '6๊ฐ์', '12๊ฐ์']
|
| 24 |
-
|
| 25 |
-
# DataFrame ์์ฑ
|
| 26 |
-
df = pd.DataFrame({
|
| 27 |
-
'์ด์ฉ์ผ': [d.strftime('%Y-%m-%d') for d in sorted(dates, reverse=True)],
|
| 28 |
-
'์ด์ฉ์นด๋': np.random.choice(cards, n),
|
| 29 |
-
'์ด์ฉ๊ฐ๋งน์ ': np.random.choice(merchants, n),
|
| 30 |
-
'์ด์ฉ๊ธ์ก': np.random.randint(5000, 500000, n),
|
| 31 |
-
})
|
| 32 |
-
|
| 33 |
-
# ํ ๋ถ/ํ์ฐจ
|
| 34 |
-
df['ํ ๋ถ/ํ์ฐจ'] = np.random.choice(installments, n)
|
| 35 |
-
|
| 36 |
-
# ์ ๋ฆฝ/ํ ์ธ์จ (0~5%)
|
| 37 |
-
df['์ ๋ฆฝ/ํ ์ธ์จ(%)'] = np.random.uniform(0.5, 5.0, n).round(2)
|
| 38 |
-
|
| 39 |
-
# ์์์ ๋ฆฝ/ํ ์ธ = ์ด์ฉ๊ธ์ก * ์ ๋ฆฝ์จ
|
| 40 |
-
df['์์์ ๋ฆฝ/ํ ์ธ'] = (df['์ด์ฉ๊ธ์ก'] * df['์ ๋ฆฝ/ํ ์ธ์จ(%)'] / 100).round(0).astype(int)
|
| 41 |
-
|
| 42 |
-
# ๊ฒฐ์ ์๊ธ = ์ด์ฉ๊ธ์ก - ์์์ ๋ฆฝ/ํ ์ธ
|
| 43 |
-
df['๊ฒฐ์ ์๊ธ'] = df['์ด์ฉ๊ธ์ก'] - df['์์์ ๋ฆฝ/ํ ์ธ']
|
| 44 |
-
|
| 45 |
-
# ๊ฒฐ์ ํ์์ก (๋์ ๊ณ์ฐ)
|
| 46 |
-
df['๊ฒฐ์ ํ์์ก'] = df['๊ฒฐ์ ์๊ธ'].cumsum()
|
| 47 |
-
|
| 48 |
-
# ์์๋ฃ(์ด์) - ํ ๋ถ์ผ ๊ฒฝ์ฐ๋ง ๋ฐ์
|
| 49 |
-
df['์์๋ฃ(์ด์)'] = 0
|
| 50 |
-
installment_mask = ~df['ํ ๋ถ/ํ์ฐจ'].isin(['์ผ์๋ถ'])
|
| 51 |
-
df.loc[installment_mask, '์์๋ฃ(์ด์)'] = np.random.randint(1000, 10000, installment_mask.sum())
|
| 52 |
-
return df
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
def preprocess_rawdata(file):
|
| 56 |
-
print(file)
|
| 57 |
-
return generate_samples()
|
| 58 |
|
| 59 |
with gr.Blocks() as demo:
|
| 60 |
with gr.Row():
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import numpy as np
|
| 3 |
import pandas as pd
|
| 4 |
+
import subprocess
|
| 5 |
from datetime import datetime, timedelta
|
| 6 |
|
| 7 |
+
def preprocess_rawdata(files):
|
| 8 |
+
print(files)
|
| 9 |
+
dfs = []
|
| 10 |
+
for file in files:
|
| 11 |
+
print(file)
|
| 12 |
+
df = pd.read_html(file, header=2)[0]
|
| 13 |
+
dfs.append(df)
|
| 14 |
+
return pd.concat(dfs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
with gr.Blocks() as demo:
|
| 17 |
with gr.Row():
|