Spaces:
Runtime error
Runtime error
import pandas as pd | |
import numpy as np | |
import random | |
def create_mock_data_heatmap(): | |
# ๊ธฐ๋ณธ ๊ตฌ์กฐ ์์ฑ | |
sections = [f'๊ตฌ์ญ {i}' for i in range(1, 7)] | |
months = list(range(1, 13)) | |
years = list(range(2020, 2025)) | |
# ๋ฐ์ดํฐํ๋ ์์ฉ ๋ฆฌ์คํธ ์์ฑ | |
data = [] | |
for year in years: | |
for section in sections: | |
for month in months: | |
data.append({ | |
'section': section, | |
'month': month, | |
'year': year, | |
'crowd_count': np.random.randint(30000, 500000) | |
}) | |
# DataFrame ์์ฑ | |
df = pd.DataFrame(data) | |
return df | |
def create_mock_data_table(): | |
mock_data = { | |
'section': [f'๊ตฌ์ญ {i}' for i in range(1, 7)], | |
'count': np.random.randint(10000, 300000, 6) | |
} | |
df = pd.DataFrame(mock_data) | |
return df | |
def create_mock_data_donut(min_value=10000, max_value=500000): | |
""" | |
๊ฐ์์ ์ธ๊ตฌ ์ด๋ ๋ฐ์ดํฐ๋ฅผ ์์ฑํฉ๋๋ค. | |
Returns: | |
tuple: (์ธ๋ฐ์ด๋ ์ด๋ ๋น์จ, ์์๋ฐ์ด๋ ์ด๋ ๋น์จ) | |
""" | |
# ๋๋ค ๊ฐ ์์ฑ (10000~500000 ์ฌ์ด) | |
inbound = random.randint(min_value, max_value) | |
outbound = random.randint(min_value, max_value) | |
# ์ ์ฒด ๊ฐ ๋๋น ๋น์จ ๊ณ์ฐ (0-100 ์ฌ์ด์ ๊ฐ์ผ๋ก ๋ณํ) | |
total = inbound + outbound | |
inbound_percent = round((inbound / total) * 100) | |
outbound_percent = round((outbound / total) * 100) | |
return inbound_percent, outbound_percent | |
def create_mock_data_inout(): | |
""" | |
๋ฐฉ๋ฌธ๊ฐ ๋ฐ์ดํฐ ๋๋ค ์์ฑ | |
- ์ด๋ฒ๋ฌ ๋ฐฉ๋ฌธ๊ฐ: 150,000 ~ 500,000 | |
- ์ค๋ ๋ฐฉ๋ฌธ๊ฐ: 5,000 ~ 100,000 | |
- delta๋ ์ ์/์ ์ผ ๋๋น ์ฆ๊ฐ๋ (-30% ~ +30%) | |
""" | |
# ์ด๋ฒ๋ฌ ๋ฐฉ๋ฌธ๊ฐ (๋ ํฐ ๋ฒ์) | |
monthly_visitors = random.randint(150000, 500000) | |
monthly_delta = int(monthly_visitors * random.uniform(-0.3, 0.3)) # 30% ๋ฒ์ ๋ด ์ฆ๊ฐ | |
# ์ค๋ ๋ฐฉ๋ฌธ๊ฐ (๋ ์์ ๋ฒ์) | |
daily_visitors = random.randint(5000, 100000) | |
daily_delta = int(daily_visitors * random.uniform(-0.3, 0.3)) # 30% ๋ฒ์ ๋ด ์ฆ๊ฐ | |
return { | |
'top': { | |
'state': '์ด๋ฒ๋ฌ ๋ฐฉ๋ฌธ๊ฐ', | |
'visitor': monthly_visitors, | |
'delta': monthly_delta | |
}, | |
'bottom': { | |
'state': '์ค๋ ๋ฐฉ๋ฌธ๊ฐ', | |
'visitor': daily_visitors, | |
'delta': daily_delta | |
} | |
} |