Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,10 @@ import requests
|
|
5 |
import plotly.express as px
|
6 |
import matplotlib.font_manager as fm
|
7 |
import matplotlib as mpl
|
8 |
-
import io
|
|
|
|
|
|
|
9 |
|
10 |
# Define URLs
|
11 |
urls = {
|
@@ -19,7 +22,8 @@ def load_data():
|
|
19 |
dataframes = {}
|
20 |
for name, url in urls.items():
|
21 |
response = requests.get(url)
|
22 |
-
|
|
|
23 |
df = df.fillna(0) # Replace missing values with 0
|
24 |
dataframes[name] = df
|
25 |
return dataframes
|
@@ -52,6 +56,5 @@ font_url = "https://drive.google.com/uc?id=1eGAsTN1HBpJAkeVM57_C7ccp7hbgSz3_&exp
|
|
52 |
font_response = requests.get(font_url)
|
53 |
with open("TaipeiSansTCBeta-Regular.ttf", "wb") as font_file:
|
54 |
font_file.write(font_response.content)
|
55 |
-
|
56 |
fm.fontManager.addfont("TaipeiSansTCBeta-Regular.ttf")
|
57 |
-
mpl.rc('font', family='Taipei Sans TC Beta')
|
|
|
5 |
import plotly.express as px
|
6 |
import matplotlib.font_manager as fm
|
7 |
import matplotlib as mpl
|
8 |
+
import io
|
9 |
+
|
10 |
+
# Ensure proper encoding for Chinese characters
|
11 |
+
st.set_page_config(page_title="ESG 專題數據分析", page_icon=":chart_with_upwards_trend:", layout="wide")
|
12 |
|
13 |
# Define URLs
|
14 |
urls = {
|
|
|
22 |
dataframes = {}
|
23 |
for name, url in urls.items():
|
24 |
response = requests.get(url)
|
25 |
+
response.encoding = 'utf-8' # Set encoding to UTF-8
|
26 |
+
df = pd.read_csv(io.StringIO(response.text), encoding='utf-8')
|
27 |
df = df.fillna(0) # Replace missing values with 0
|
28 |
dataframes[name] = df
|
29 |
return dataframes
|
|
|
56 |
font_response = requests.get(font_url)
|
57 |
with open("TaipeiSansTCBeta-Regular.ttf", "wb") as font_file:
|
58 |
font_file.write(font_response.content)
|
|
|
59 |
fm.fontManager.addfont("TaipeiSansTCBeta-Regular.ttf")
|
60 |
+
mpl.rc('font', family='Taipei Sans TC Beta')
|