jnaiman commited on
Commit
98498ae
·
1 Parent(s): 8c6152b
Files changed (3) hide show
  1. README.md +12 -2
  2. app.py +416 -57
  3. requirements.txt +4 -2
README.md CHANGED
@@ -1,13 +1,23 @@
1
  ---
2
- title: My IS445 Example ID48914
3
  emoji: 🏢
4
  colorFrom: blue
5
  colorTo: gray
6
  sdk: streamlit
7
- sdk_version: 1.36.0
8
  app_file: app.py
9
  pinned: false
10
  license: mit
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ title: Prep notebook -- My Streamlit App (Day 1)
3
  emoji: 🏢
4
  colorFrom: blue
5
  colorTo: gray
6
  sdk: streamlit
7
+ sdk_version: 1.39.0
8
  app_file: app.py
9
  pinned: false
10
  license: mit
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
14
+
15
+ # Info:
16
+ This is the "prep" notebook for a introductory Streamlit app for IS445.
17
+
18
+ ## How to teach with this:
19
+ We will build this "from scratch" during class using the following steps:
20
+ 1. Make sure your repo is cloned in your PraireLearn (this will be "is445_demo2" with my setup, "is445_demo" for each of the students)
21
+ 1. Update the README.md if the app.py file has changed names
22
+ 1. Copy what we did from last week to the app.py file here
23
+ 1. Update the requirements.txt file to include libraries (see whats in here now)
app.py CHANGED
@@ -1,73 +1,432 @@
1
- # INSTRUCTIONS:
2
- # 1. Open a "Terminal" by: View --> Terminal OR just the "Terminal" through the hamburger menu
3
- # 2. run in terminal with: streamlit run app.py
4
- # 3. click the "Open in Browser" link that pops up OR click on "Ports" and copy the URL
5
- # 4. Open a Simple Browswer with View --> Command Palette --> Simple Browser: Show
6
- # 5. use the URL from prior steps as intput into this simple browser
7
 
 
 
 
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  import streamlit as st
10
  import altair as alt
11
- from vega_datasets import data
12
-
13
- st.title('Streamlit App for IS445: ID48914')
14
 
15
- st.text("The URL for this app is: https://huggingface.co/spaces/jnaiman/testing_is445_demo")
 
 
16
 
17
- source = data.seattle_weather()
18
 
19
- scale = alt.Scale(
20
- domain=["sun", "fog", "drizzle", "rain", "snow"],
21
- range=["#e7ba52", "#a7a7a7", "#aec7e8", "#1f77b4", "#9467bd"],
 
 
22
  )
23
- color = alt.Color("weather:N", scale=scale)
24
-
25
- # We create two selections:
26
- # - a brush that is active on the top panel
27
- # - a multi-click that is active on the bottom panel
28
- brush = alt.selection_interval(encodings=["x"])
29
- click = alt.selection_point(encodings=["color"])
30
-
31
- # Top panel is scatter plot of temperature vs time
32
- points = (
33
- alt.Chart()
34
- .mark_point()
35
- .encode(
36
- alt.X("monthdate(date):T", title="Date (Month Year)"),
37
- alt.Y(
38
- "temp_max:Q",
39
- title="Maximum Daily Temperature (C)",
40
- scale=alt.Scale(domain=[-5, 40]),
41
- ),
42
- color=alt.condition(brush, color, alt.value("lightgray")),
43
- size=alt.Size("precipitation:Q", scale=alt.Scale(range=[5, 200])),
44
- )
45
- .properties(width=550, height=300)
46
- .add_params(brush)
47
- .transform_filter(click)
48
  )
49
 
50
- # Bottom panel is a bar chart of weather type
51
- bars = (
52
- alt.Chart()
53
- .mark_bar()
54
- .encode(
55
- x="count()",
56
- y="weather:N",
57
- color=alt.condition(click, color, alt.value("lightgray")),
58
- )
59
- .transform_filter(brush)
60
- .properties(
61
- width=550,
62
- )
63
- .add_params(click)
64
  )
65
 
66
- chart = alt.vconcat(points, bars, data=source, title="Seattle Weather - 2003 to 2008")
67
 
68
- tab1, tab2 = st.tabs(["Streamlit theme (default)", "Altair native theme"])
69
 
70
  with tab1:
71
- st.altair_chart(chart, theme="streamlit", use_container_width=True)
72
  with tab2:
73
- st.altair_chart(chart, theme=None, use_container_width=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
 
2
+ #######################################################
3
+ # 1. Getting setup -- using our HF template
4
+ #######################################################
5
 
6
+ # We have a few options for how to proceed. I'll start by showing the process in
7
+ # PL and then I'll move to my local installation of my template so that I can make
8
+ # sure I am pushing code at various intervals so folks can check that out.
9
+
10
+ # NOTE: during this process, you can click on "Always Rerun" for automatic updates.
11
+
12
+ # See the class notes on this with some photos for reference!
13
+ # **this has to be implemented!**
14
+
15
+
16
+ ###################################################################
17
+ # 2. Review of where we got to last time, in template app.py file
18
+ ###################################################################
19
+
20
+
21
+ # Let's start by copying things we did last time
22
  import streamlit as st
23
  import altair as alt
 
 
 
24
 
25
+ # Let's recall a plot that we made with Altair in Jupyterlab:
26
+ # Make sure we copy the URL as well!
27
+ mobility_url = 'https://raw.githubusercontent.com/UIUC-iSchool-DataViz/is445_data/main/mobility.csv'
28
 
29
+ st.title('This is my fancy app for HuggingFace!!')
30
 
31
+ scatters = alt.Chart(mobility_url).mark_point().encode(
32
+ x='Mobility:Q', # "Q for quantiative"
33
+ #y='Population:Q',
34
+ y=alt.Y('Population:Q', scale=alt.Scale(type='log')),
35
+ color=alt.Color('Income:Q', scale=alt.Scale(scheme='sinebow'),bin=alt.Bin(maxbins=5))
36
  )
37
+
38
+ st.header('More complex Dashboards')
39
+
40
+ brush = alt.selection_interval(encodings=['x','y'])
41
+
42
+ chart1 = alt.Chart(mobility_url).mark_rect().encode(
43
+ alt.X("Student_teacher_ratio:Q", bin=alt.Bin(maxbins=10)),
44
+ alt.Y("State:O"),
45
+ alt.Color("count()")
46
+ ).properties(
47
+ height=400
48
+ ).add_params(
49
+ brush
 
 
 
 
 
 
 
 
 
 
 
 
50
  )
51
 
52
+ chart2 = alt.Chart(mobility_url).mark_bar().encode(
53
+ alt.X("Mobility:Q", bin=True,axis=alt.Axis(title='Mobility Score')),
54
+ alt.Y('count()', axis=alt.Axis(title='Mobility Score Distribution'))
55
+ ).transform_filter(
56
+ brush
 
 
 
 
 
 
 
 
 
57
  )
58
 
59
+ chart = (chart1.properties(width=300) | chart2.properties(width=300))
60
 
61
+ tab1, tab2 = st.tabs(["Mobility interactive", "Scatter plot"])
62
 
63
  with tab1:
64
+ st.altair_chart(chart, theme=None, use_container_width=True)
65
  with tab2:
66
+ st.altair_chart(scatters, theme=None, use_container_width=True)
67
+
68
+
69
+ ################################################
70
+ # 3. Adding features, Pushing to HF
71
+ ################################################
72
+
73
+ st.header('Requirements, README file, Pushing to HuggingFace')
74
+
75
+ ### 3.1 Make a plot ###
76
+
77
+ # Let's say we want to add in some matplotlib plots from some data we read
78
+ # in with Pandas.
79
+
80
+ import pandas as pd
81
+ df = pd.read_csv(mobility_url)
82
+
83
+ # There are a few ways to show the dataframe if we want our viewer to see the table:
84
+ #df
85
+ st.write(df)
86
+
87
+ # Now, let's plot with matplotlib:
88
+ import matplotlib.pyplot as plt
89
+
90
+ fig, ax = plt.subplots()
91
+ df['Seg_income'].plot(kind='hist', ax=ax)
92
+ #plt.show() # but wait! this doesn't work!
93
+
94
+ # We need to use the streamlit-specific way of showing matplotlib plots: https://docs.streamlit.io/develop/api-reference/charts/st.pyplot
95
+ st.pyplot(fig)
96
+
97
+ ### 3.2 Push these changes to HF -- requirements.txt ###
98
+ # In order to push these changes to HF and have things actually show up we need to
99
+ # add the packages we've added to our requirements.txt file.
100
+
101
+ st.write('''The requirements.txt file contains all the packages needed
102
+ for our app to run. These include (for our application):''')
103
+ st.code('''
104
+ streamlit==1.39.0
105
+ altair
106
+ numpy
107
+ pandas
108
+ matplotlib
109
+ ''')
110
+
111
+ # NOTE: for any package you want to use in your app.py file, you must include it in
112
+ # the requirements.txt file!
113
+
114
+ # Note #2: we specified a version of streamlit so we can use some specific widgets
115
+
116
+ ### 3.3 Push these changes to HF -- README.md ###
117
+
118
+ # While we're doing this, let's also take a look at the README.md file!
119
+
120
+ st.header('Build in HF: README.md & requirements.txt files')
121
+
122
+ st.code('''
123
+ ---
124
+ title: Prep notebook -- My Streamlit App
125
+ emoji: 🏢
126
+ colorFrom: blue
127
+ colorTo: gray
128
+ sdk: streamlit
129
+ sdk_version: 1.39.0
130
+ app_file: app.py
131
+ pinned: false
132
+ license: mit
133
+ ---
134
+ ''')
135
+ st.write("Note: the sdk version has to match what is in your requirements.txt (and with whatever widgets you want to be able to use).")
136
+
137
+ # Some important things to note here:
138
+
139
+ st.write('Some important items to note about these:')
140
+ st.markdown('''
141
+ * the "emoji" is what will show up as an identifier on your homepage
142
+ * the sdk *must* be streamlit
143
+ * the "app_file" *must* link to the app file you are developing in
144
+ ''')
145
+
146
+ ################################################
147
+ # 4. TODO Quick intro to widgets
148
+ ################################################
149
+
150
+ st.header('Widgets in Streamlit apps')
151
+
152
+ ### 4.1 Widget basics: A few widget examples ###
153
+
154
+ st.markdown("""
155
+ These will be very similar to how we used the `ipywidgets` package in Jupyter notebooks.
156
+ """)
157
+
158
+ st.markdown("""
159
+ We won't go over all of them, but you can check out the [list of widgets](https://docs.streamlit.io/develop/api-reference/widgets)
160
+ linked.
161
+ """)
162
+
163
+ st.markdown("""Let's try a few!""")
164
+
165
+ st.subheader('Feedback Widget')
166
+
167
+ st.markdown("""
168
+ For example, we could try the [feedback widget](https://docs.streamlit.io/develop/api-reference/widgets/st.feedback).
169
+ """
170
+ )
171
+ st.markdown("""
172
+ If we check out the docs for this widget, we see some familiar looking functions like
173
+ `on_change` and the example they give looks very similar to an
174
+ "observation" function that we built before using widgets:
175
+ """)
176
+
177
+ st.code(
178
+ """
179
+ sentiment_mapping = ["one", "two", "three", "four", "five"]
180
+ selected = st.feedback("stars")
181
+ if selected is not None:
182
+ st.markdown(f"You selected {sentiment_mapping[selected]} star(s).")
183
+ """)
184
+
185
+ # Let's give this a shot!
186
+
187
+ st.write("How great are you feeling right now?")
188
+ sentiment_mapping = ["one", "two", "three", "four", "five"] # map to these numers
189
+ selected = st.feedback("stars")
190
+ if selected is not None: # make sure we have a selection
191
+ st.markdown(f"You selected {sentiment_mapping[selected]} star(s).")
192
+ if selected < 1:
193
+ st.markdown('Sorry to hear you are so sad :(')
194
+ elif selected < 3:
195
+ st.markdown('A solid medium is great!')
196
+ else:
197
+ st.markdown('Fantastic you are having such a great day!')
198
+
199
+ st.subheader('Radio Buttons')
200
+
201
+ st.markdown("""
202
+ Let's try out a [radio button](https://docs.streamlit.io/develop/api-reference/widgets/st.radio) example.
203
+ """)
204
+
205
+ favoriteViz = st.radio(
206
+ "What's your visualization tool so far?",
207
+ [":rainbow[Streamlit]", "vega-lite :sparkles:", "matplotlib :material/Home:"],
208
+ captions=[
209
+ "New and cool!",
210
+ "So sparkly.",
211
+ "Familiar and comforting.",
212
+ ],
213
+ )
214
+
215
+ if favoriteViz == ":rainbow[Streamlit]":
216
+ st.write("You selected Streamlit!")
217
+ else:
218
+ st.write("You didn't select Streamlit but that's ok, Data Viz still likes you :grin:")
219
+
220
+ st.markdown("""
221
+ Note here that we made use of text highlight [colors](https://docs.streamlit.io/develop/api-reference/text/st.markdown)
222
+ and [emoji's](https://streamlit-emoji-shortcodes-streamlit-app-gwckff.streamlit.app/)
223
+ and [icons](https://fonts.google.com/icons?icon.set=Material+Symbols&icon.style=Rounded).
224
+ """)
225
+
226
+ ### 4.2 Connecting widgets with plots ###
227
+
228
+ st.subheader('Connecting Widgets and Plots')
229
+
230
+
231
+ st.markdown("""
232
+ There are actually [many types of charts](https://docs.streamlit.io/develop/api-reference/charts)
233
+ supported in Streamlit (including the Streamlit-based "Simple Charts"),
234
+ though we will just mainly be focusing on [Altair-related](https://docs.streamlit.io/develop/api-reference/charts/st.altair_chart) plots
235
+ and their interactivity options since we'll also be making use of these when
236
+ we move to building Jekyll webpages.
237
+ """)
238
+
239
+ st.markdown("""Since `matplotlib` is relatively familiar though, let's do a quick
240
+ example using `pandas` and `matplotlib` to plot as
241
+ Streamlit [does support `matplotlib`](https://docs.streamlit.io/develop/api-reference/charts/st.pyplot)
242
+ as a plotting engine. """)
243
+
244
+ st.markdown("""First, let's just make a simple plot with `pandas` and `matplotlib`.
245
+ Let's re-do the matplotlib plots we did before with the mobility dataset
246
+ with some interactivity. """)
247
+
248
+ import pandas as pd
249
+ import numpy as np
250
+
251
+ # first, let's make a static plot:
252
+ st.write("We'll start with a static plot:")
253
+ # read in dataset
254
+ df = pd.read_csv("https://raw.githubusercontent.com/UIUC-iSchool-DataViz/is445_data/main/mobility.csv")
255
+
256
+ # make bins along student-teacher ratio
257
+ bins = np.linspace(df['Student_teacher_ratio'].min(),df['Student_teacher_ratio'].max(), 10)
258
+
259
+ # make pivot table
260
+ table = df.pivot_table(index='State', columns=pd.cut(df['Student_teacher_ratio'], bins), aggfunc='size')
261
+
262
+ # our plotting code before was:
263
+ st.code("""
264
+ import matplotlib.pyplot as plt
265
+
266
+ fig,ax = plt.subplots(figsize=(10,8))
267
+ ax.imshow(table.values, cmap='hot', interpolation='nearest')
268
+ ax.set_yticks(range(len(table.index)))
269
+ ax.set_yticklabels(table.index)
270
+ plt.show()
271
+ """)
272
+
273
+ st.write("Let's translate it into something that will work with Streamlit:")
274
+
275
+ import matplotlib.pyplot as plt
276
+
277
+ fig,ax = plt.subplots() # this changed
278
+ ax.imshow(table.values, cmap='hot', interpolation='nearest')
279
+ ax.set_yticks(range(len(table.index)))
280
+ ax.set_yticklabels(table.index)
281
+
282
+ st.pyplot(fig) # this is different
283
+
284
+ st.markdown("""But this is too big! The trick is that we can save this as a buffer: """)
285
+
286
+ from io import BytesIO
287
+
288
+ fig,ax = plt.subplots(figsize=(4,8)) # this changed
289
+ ax.imshow(table.values, cmap='hot', interpolation='nearest')
290
+ ax.set_yticks(range(len(table.index)))
291
+ ax.set_yticklabels(table.index)
292
+
293
+ buf = BytesIO()
294
+ fig.tight_layout()
295
+ fig.savefig(buf, format="png")
296
+ st.image(buf, width = 500) # can mess around with width, figsize/etc
297
+
298
+ st.write("Now, let's make this interactive.")
299
+ st.markdown("""We'll first use the [multiselect](https://docs.streamlit.io/develop/api-reference/widgets/st.multiselect)
300
+ tool in order to allow for multiple state selection. """)
301
+
302
+ # vertical alignment so they end up side by side
303
+ fig_col, controls_col = st.columns([2,1], vertical_alignment='center')
304
+
305
+ # multi-select
306
+ states_selected = controls_col.multiselect('Which states do you want to view?', table.index.values)
307
+
308
+ if len(states_selected) > 0:
309
+ df_subset = df[df['State'].isin(states_selected)] # changed
310
+
311
+ # make pivot table -- changed
312
+ table_sub = df_subset.pivot_table(index='State',
313
+ columns=pd.cut(df_subset['Student_teacher_ratio'], bins),
314
+ aggfunc='size')
315
+
316
+ base_size = 4
317
+ # this resizing doesn't 100% work great
318
+ #factor = len(table.index)*1.0/df['State'].nunique()
319
+ #if factor == 0: factor = 1 # for non-selections
320
+ #fig,ax = plt.subplots(figsize=(base_size,2*base_size*factor)) # this changed too for different size
321
+ fig,ax = plt.subplots(figsize=(base_size,2*base_size)) # this changed too for different size
322
+ # extent is (xmin, xmax, ymax (buttom), ymin (top))
323
+ extent = [bins.min(), bins.max(), 0, len(table_sub.index)]
324
+ ax.imshow(table_sub.values, cmap='hot', interpolation='nearest',
325
+ extent=extent)
326
+ ax.set_yticks(range(len(table_sub.index)))
327
+ ax.set_yticklabels(table_sub.index)
328
+ #ax.set_xticklabels(bins)
329
+
330
+ buf = BytesIO()
331
+ fig.tight_layout()
332
+ fig.savefig(buf, format="png")
333
+ fig_col.image(buf, width = 400) # changed here to fit better
334
+ else:
335
+ fig,ax = plt.subplots(figsize=(4,8)) # this changed
336
+ extent = [bins.min(), bins.max(), 0, len(table.index)]
337
+ ax.imshow(table.values, cmap='hot', interpolation='nearest', extent=extent)
338
+ ax.set_yticks(range(len(table.index)))
339
+ ax.set_yticklabels(table.index)
340
+ #ax.set_xticklabels(bins)
341
+
342
+ buf = BytesIO()
343
+ fig.tight_layout()
344
+ fig.savefig(buf, format="png")
345
+ fig_col.image(buf, width = 500) # can mess around with width, figsize/etc
346
+
347
+
348
+ st.markdown("""
349
+ Now let's add more in by including a [range slider](https://docs.streamlit.io/develop/api-reference/widgets/st.slider)
350
+ widget.
351
+ """)
352
+
353
+ # vertical alignment so they end up side by side
354
+ fig_col2, controls_col2 = st.columns([2,1], vertical_alignment='center')
355
+
356
+ # multi-select
357
+ states_selected2 = controls_col2.multiselect('Which states do you want to view?',
358
+ table.index.values, key='unik1155')
359
+ # had to pass unique key to have double widgets with same value
360
+
361
+ # range slider -- added
362
+ student_teacher_ratio_range = controls_col2.slider("Range of student teacher ratio:",
363
+ df['Student_teacher_ratio'].min(),
364
+ df['Student_teacher_ratio'].max(),
365
+ (0.25*df['Student_teacher_ratio'].mean(),
366
+ 0.75*df['Student_teacher_ratio'].mean()))
367
+
368
+ # note all the "2's" here, probably will just update the original one
369
+ if len(states_selected2) > 0: # here we set a default value for the slider, so no need to have a tag
370
+ min_range = student_teacher_ratio_range[0] # added
371
+ max_range = student_teacher_ratio_range[1] # added
372
+
373
+ df_subset2 = df[(df['State'].isin(states_selected2)) & (df['Student_teacher_ratio'] >= min_range) & (df['Student_teacher_ratio']<=max_range)] # changed
374
+
375
+ # just 10 bins over the full range --> changed
376
+ bins2 = 10 #np.linspace(df['Student_teacher_ratio'].min(),df['Student_teacher_ratio'].max(), 10)
377
+
378
+ # make pivot table -- changed
379
+ table_sub2 = df_subset2.pivot_table(index='State',
380
+ columns=pd.cut(df_subset2['Student_teacher_ratio'], bins2),
381
+ aggfunc='size')
382
+
383
+ base_size = 4
384
+ fig2,ax2 = plt.subplots(figsize=(base_size,2*base_size)) # this changed too for different size
385
+ extent2 = [df_subset2['Student_teacher_ratio'].min(),
386
+ df_subset2['Student_teacher_ratio'].max(),
387
+ 0, len(table_sub2.index)]
388
+ ax2.imshow(table_sub2.values, cmap='hot', interpolation='nearest', extent=extent2)
389
+ ax2.set_yticks(range(len(table_sub2.index)))
390
+ ax2.set_yticklabels(table_sub2.index)
391
+ #ax2.set_xticklabels()
392
+
393
+ buf2 = BytesIO()
394
+ fig2.tight_layout()
395
+ fig2.savefig(buf2, format="png")
396
+ fig_col2.image(buf2, width = 400) # changed here to fit better
397
+ else:
398
+ min_range = student_teacher_ratio_range[0] # added
399
+ max_range = student_teacher_ratio_range[1] # added
400
+
401
+ df_subset2 = df[(df['Student_teacher_ratio'] >= min_range) & (df['Student_teacher_ratio']<=max_range)] # changed
402
+
403
+ # just 10 bins over the full range --> changed
404
+ bins2 = 10 #np.linspace(df['Student_teacher_ratio'].min(),df['Student_teacher_ratio'].max(), 10)
405
+
406
+ # make pivot table -- changed
407
+ table_sub2 = df_subset2.pivot_table(index='State',
408
+ columns=pd.cut(df_subset2['Student_teacher_ratio'], bins2),
409
+ aggfunc='size')
410
+
411
+ base_size = 4
412
+ fig2,ax2 = plt.subplots(figsize=(base_size,2*base_size)) # this changed too for different size
413
+ extent2 = [df_subset2['Student_teacher_ratio'].min(),
414
+ df_subset2['Student_teacher_ratio'].max(),
415
+ 0, len(table_sub2.index)]
416
+ ax2.imshow(table_sub2.values, cmap='hot', interpolation='nearest', extent=extent2)
417
+ ax2.set_yticks(range(len(table_sub2.index)))
418
+ ax2.set_yticklabels(table_sub2.index)
419
+ #ax2.set_xticklabels()
420
+
421
+ buf2 = BytesIO()
422
+ fig2.tight_layout()
423
+ fig2.savefig(buf2, format="png")
424
+ fig_col2.image(buf2, width = 400) # changed here to fit better
425
+
426
+ st.header('Push final page to HF')
427
+ st.markdown("""When ready, do:""")
428
+ st.code("""
429
+ git add -A
430
+ git commit -m "final push of day 1"
431
+ git push
432
+ """)
requirements.txt CHANGED
@@ -1,3 +1,5 @@
1
- streamlit
2
  altair
3
- vega_datasets
 
 
 
1
+ streamlit==1.39.0
2
  altair
3
+ numpy
4
+ pandas
5
+ matplotlib