Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,84 @@
|
|
1 |
import gradio as gr
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
with gr.Blocks() as demo:
|
5 |
-
with gr.Tab("
|
6 |
-
gr.
|
7 |
-
gr.Button("
|
8 |
-
|
9 |
-
gr.Image("tiger.jpg")
|
10 |
-
gr.Button("New Tiger")
|
11 |
|
12 |
|
13 |
if __name__ == "__main__":
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
# Capex in Millions of USD per Quarter of Microsoft, Google, Meta, Apple, Amazon
|
4 |
+
big_five_capex: list[tuple[str, int, int, int, int, int]] = [
|
5 |
+
("2014 Q3", 1282, 2417, 482, 3826, 1378),
|
6 |
+
("2014 Q4", 1490, 3606, 517, 3217, 1145),
|
7 |
+
("2015 Q1", 1391, 2927, 502, 2369, 871),
|
8 |
+
("2015 Q2", 1781, 2515, 549, 2043, 1213),
|
9 |
+
("2015 Q3", 1356, 2406, 780, 3618, 1195),
|
10 |
+
("2015 Q4", 2024, 2102, 692, 3612, 1309),
|
11 |
+
("2016 Q1", 2308, 2444, 1132, 2336, 1179),
|
12 |
+
("2016 Q2", 2655, 2136, 995, 2809, 1711),
|
13 |
+
("2016 Q3", 2163, 2554, 1095, 3977, 1841),
|
14 |
+
("2016 Q4", 1988, 3078, 1269, 3334, 3073),
|
15 |
+
("2017 Q1", 1695, 2508, 1271, 2975, 2148),
|
16 |
+
("2017 Q2", 2283, 2831, 1444, 2277, 3113),
|
17 |
+
("2017 Q3", 2132, 3538, 1755, 3865, 3074),
|
18 |
+
("2017 Q4", 2586, 4307, 2263, 2810, 3619),
|
19 |
+
("2018 Q1", 2934, 7299, 2812, 4195, 3098),
|
20 |
+
("2018 Q2", 3980, 5477, 3460, 3267, 3243),
|
21 |
+
("2018 Q3", 3602, 5282, 3342, 3041, 3352),
|
22 |
+
("2018 Q4", 3707, 7081, 4301, 3355, 3734),
|
23 |
+
("2019 Q1", 2565, 4638, 3837, 2363, 3290),
|
24 |
+
("2019 Q2", 4051, 6126, 3633, 2000, 3562),
|
25 |
+
("2019 Q3", 3385, 6732, 3532, 2777, 4697),
|
26 |
+
("2019 Q4", 3545, 6052, 4100, 2107, 5312),
|
27 |
+
("2020 Q1", 3767, 6005, 3558, 1853, 6795),
|
28 |
+
("2020 Q2", 4744, 5391, 3255, 1565, 7459),
|
29 |
+
("2020 Q3", 4907, 5406, 3689, 1784, 11063),
|
30 |
+
("2020 Q4", 4174, 5479, 4613, 3500, 14823),
|
31 |
+
("2021 Q1", 5089, 5942, 4303, 2269, 12082),
|
32 |
+
("2021 Q2", 6452, 5496, 4641, 2093, 14288),
|
33 |
+
("2021 Q3", 5810, 6819, 4346, 3223, 15748),
|
34 |
+
("2021 Q4", 5865, 6383, 5400, 2803, 18935),
|
35 |
+
("2022 Q1", 5340, 9786, 5441, 2514, 14951),
|
36 |
+
("2022 Q2", 6871, 6828, 7572, 2102, 15724),
|
37 |
+
("2022 Q3", 6283, 7276, 9375, 3289, 16378),
|
38 |
+
("2022 Q4", 6274, 7595, 9043, 3787, 16592),
|
39 |
+
("2023 Q1", 6607, 6289, 6823, 2916, 14207),
|
40 |
+
("2023 Q2", 8943, 6888, 6134, 2093, 11455),
|
41 |
+
("2023 Q3", 9917, 8055, 6543, 2163, 12479),
|
42 |
+
("2023 Q4", 9735, 11019, 7665, 2392, 14588),
|
43 |
+
("2024 Q1", 10952, 12012, 6400, 1996, 14925),
|
44 |
+
("2024 Q2", 13873, 13186, 8173, 2151, 17620),
|
45 |
+
]
|
46 |
+
|
47 |
+
|
48 |
+
def create_chart():
|
49 |
+
df = pd.DataFrame(big_five_capex, columns=['Quarter', 'Microsoft', 'Google', 'Meta', 'Apple', 'Amazon'])
|
50 |
+
|
51 |
+
fig = go.Figure()
|
52 |
+
|
53 |
+
companies = ['Microsoft', 'Google', 'Meta', 'Apple', 'Amazon']
|
54 |
+
colors = ['#00a1f1', '#3cba54', '#1877f2', '#a2aaad', '#ff9900']
|
55 |
+
|
56 |
+
for company, color in zip(companies, colors):
|
57 |
+
fig.add_trace(go.Bar(
|
58 |
+
x=df['Quarter'],
|
59 |
+
y=df[company],
|
60 |
+
name=company,
|
61 |
+
marker_color=color
|
62 |
+
))
|
63 |
+
|
64 |
+
fig.update_layout(
|
65 |
+
title='Capital Expenditure of the Big Five Tech Companies (Millions of USD per Quarter)',
|
66 |
+
xaxis_title='Quarter',
|
67 |
+
yaxis_title='Capex (Millions of USD)',
|
68 |
+
barmode='stack',
|
69 |
+
legend_title='Companies',
|
70 |
+
width=1200,
|
71 |
+
height=700
|
72 |
+
)
|
73 |
+
|
74 |
+
return fig
|
75 |
+
|
76 |
|
77 |
with gr.Blocks() as demo:
|
78 |
+
with gr.Tab("Big Five Capex"):
|
79 |
+
big_five_capex_plot: gr.Plot = gr.Plot()
|
80 |
+
generate_btn = gr.Button("Generate Plot")
|
81 |
+
generate_btn.click(fn=create_step_chart, outputs=plot_output)
|
|
|
|
|
82 |
|
83 |
|
84 |
if __name__ == "__main__":
|