whitphx HF staff commited on
Commit
9c1ffe9
β€’
1 Parent(s): 6863cfd

Copy sample files from streamlit/docs/python/api-examples-source/* (4e54057)

Browse files
This view is limited to 50 files because it contains too many changes. Β  See raw diff
Files changed (50) hide show
  1. pages/charts.area_chart.py +8 -4
  2. pages/charts.area_chart1.py +23 -0
  3. pages/charts.area_chart2.py +21 -0
  4. pages/charts.audio.py +33 -1
  5. pages/charts.bar_chart.py +8 -4
  6. pages/charts.bar_chart1.py +23 -0
  7. pages/charts.bar_chart2.py +23 -0
  8. pages/charts.graphviz_chart.py +4 -2
  9. pages/charts.line_chart.py +9 -5
  10. pages/charts.line_chart1.py +23 -0
  11. pages/charts.line_chart2.py +21 -0
  12. pages/charts.map.py +5 -3
  13. pages/charts.map_color.py +20 -0
  14. pages/charts.plotly_chart.py +5 -3
  15. pages/charts.pydeck_chart.py +1 -1
  16. pages/charts.pyplot.py +5 -3
  17. pages/charts.vega_lite_chart.py +5 -3
  18. pages/chat.echo.py +26 -0
  19. pages/chat.input.py +5 -0
  20. pages/chat.llm.py +57 -0
  21. pages/chat.message.py +6 -0
  22. pages/chat.message1.py +6 -0
  23. pages/chat.simple.py +44 -0
  24. pages/data.barchart_column.py +32 -0
  25. pages/data.checkbox_column.py +28 -0
  26. pages/data.column.py +28 -0
  27. pages/data.column_config.empty.py +15 -0
  28. pages/data.column_config.py +103 -0
  29. pages/data.data_editor.py +20 -0
  30. pages/data.data_editor1.py +20 -0
  31. pages/data.data_editor2.py +17 -0
  32. pages/data.data_editor3.py +32 -0
  33. pages/data.data_editor4.py +25 -0
  34. pages/data.data_editor_config.py +37 -0
  35. pages/data.dataframe.py +8 -4
  36. pages/data.dataframe1.py +9 -5
  37. pages/data.dataframe2.py +1 -1
  38. pages/data.dataframe_config.py +42 -0
  39. pages/data.date_column.py +35 -0
  40. pages/data.datetime_column.py +35 -0
  41. pages/data.image_column.py +29 -0
  42. pages/data.linechart_column.py +33 -0
  43. pages/data.link_column.py +32 -0
  44. pages/data.list_column.py +31 -0
  45. pages/data.number_column.py +29 -0
  46. pages/data.progress_column.py +28 -0
  47. pages/data.selectbox_column.py +37 -0
  48. pages/data.table.py +5 -3
  49. pages/data.text_column.py +28 -0
  50. pages/data.time_column.py +35 -0
pages/charts.area_chart.py CHANGED
@@ -1,12 +1,16 @@
1
- import streamlit as st
2
- import pandas as pd
3
  import numpy as np
 
 
 
4
 
5
- @st.experimental_memo
6
  def load_data():
7
- df = pd.DataFrame(np.random.randn(20, 3), columns=["a", "b", "c"])
 
 
8
  return df
9
 
 
10
  chart_data = load_data()
11
 
12
  st.area_chart(chart_data)
 
 
1
  import numpy as np
2
+ import pandas as pd
3
+ import streamlit as st
4
+
5
 
6
+ @st.cache_data
7
  def load_data():
8
+ df = pd.DataFrame(
9
+ np.random.randn(20, 3),
10
+ columns = ['a', 'b', 'c'])
11
  return df
12
 
13
+
14
  chart_data = load_data()
15
 
16
  st.area_chart(chart_data)
pages/charts.area_chart1.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pandas as pd
3
+ import streamlit as st
4
+
5
+
6
+ @st.cache_data
7
+ def load_data():
8
+ df = pd.DataFrame({
9
+ 'col1' : np.random.randn(20),
10
+ 'col2' : np.random.randn(20),
11
+ 'col3' : np.random.choice(['A','B','C'], 20)
12
+ })
13
+ return df
14
+
15
+
16
+ chart_data = load_data()
17
+
18
+ st.area_chart(
19
+ chart_data,
20
+ x = 'col1',
21
+ y = 'col2',
22
+ color = 'col3'
23
+ )
pages/charts.area_chart2.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pandas as pd
3
+ import streamlit as st
4
+
5
+
6
+ @st.cache_data
7
+ def load_data():
8
+ df = pd.DataFrame(
9
+ np.random.randn(20, 3),
10
+ columns = ['col1', 'col2', 'col3'])
11
+ return df
12
+
13
+
14
+ chart_data = load_data()
15
+
16
+ st.area_chart(
17
+ chart_data,
18
+ x = 'col1',
19
+ y = ['col2', 'col3'],
20
+ color = ['#FF0000', '#0000FF'] # Optional
21
+ )
pages/charts.audio.py CHANGED
@@ -1,8 +1,9 @@
 
1
  import requests
2
  import streamlit as st
3
 
4
 
5
- @st.experimental_memo
6
  def read_file_from_url(url):
7
  headers = {
8
  "User-Agent": "StreamlitDocs/1.5.0 (https://docs.streamlit.io; hello@streamlit.io)"
@@ -32,3 +33,34 @@ st.write(
32
 
33
  """
34
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
  import requests
3
  import streamlit as st
4
 
5
 
6
+ @st.cache_data
7
  def read_file_from_url(url):
8
  headers = {
9
  "User-Agent": "StreamlitDocs/1.5.0 (https://docs.streamlit.io; hello@streamlit.io)"
33
 
34
  """
35
  )
36
+
37
+ st.code(
38
+ """
39
+ import streamlit as st
40
+ import numpy as np
41
+
42
+ sample_rate = 44100 # 44100 samples per second
43
+ seconds = 2 # Note duration of 2 seconds
44
+
45
+ frequency_la = 440 # Our played note will be 440 Hz
46
+
47
+ # Generate array with seconds*sample_rate steps, ranging between 0 and seconds
48
+ t = np.linspace(0, seconds, seconds * sample_rate, False)
49
+
50
+ # Generate a 440 Hz sine wave
51
+ note_la = np.sin(frequency_la * t * 2 * np.pi)
52
+ st.audio(note_la, sample_rate=sample_rate)
53
+ """
54
+ )
55
+
56
+ sample_rate = 44100 # 44100 samples per second
57
+ seconds = 2 # Note duration of 2 seconds
58
+
59
+ frequency_la = 440 # Our played note will be 440 Hz
60
+
61
+ # Generate array with seconds*sample_rate steps, ranging between 0 and seconds
62
+ t = np.linspace(0, seconds, seconds * sample_rate, False)
63
+
64
+ # Generate a 440 Hz sine wave
65
+ note_la = np.sin(frequency_la * t * 2 * np.pi)
66
+ st.audio(note_la, sample_rate=sample_rate)
pages/charts.bar_chart.py CHANGED
@@ -1,12 +1,16 @@
1
- import streamlit as st
2
- import pandas as pd
3
  import numpy as np
 
 
 
4
 
5
- @st.experimental_memo
6
  def load_data():
7
- df = pd.DataFrame(np.random.randn(50, 3), columns=["a", "b", "c"])
 
 
8
  return df
9
 
 
10
  chart_data = load_data()
11
 
12
  st.bar_chart(chart_data)
 
 
1
  import numpy as np
2
+ import pandas as pd
3
+ import streamlit as st
4
+
5
 
6
+ @st.cache_data
7
  def load_data():
8
+ df = pd.DataFrame(
9
+ np.random.randn(50, 3),
10
+ columns = ["a", "b", "c"])
11
  return df
12
 
13
+
14
  chart_data = load_data()
15
 
16
  st.bar_chart(chart_data)
pages/charts.bar_chart1.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pandas as pd
3
+ import streamlit as st
4
+
5
+
6
+ @st.cache_data
7
+ def load_data():
8
+ df = pd.DataFrame({
9
+ 'col1' : list(range(20))*3,
10
+ 'col2' : np.random.randn(60),
11
+ 'col3' : ['A']*20 + ['B']*20 + ['C']*20
12
+ })
13
+ return df
14
+
15
+
16
+ chart_data = load_data()
17
+
18
+ st.bar_chart(
19
+ chart_data,
20
+ x = 'col1',
21
+ y = 'col2',
22
+ color = 'col3'
23
+ )
pages/charts.bar_chart2.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pandas as pd
3
+ import streamlit as st
4
+
5
+
6
+ @st.cache_data
7
+ def load_data():
8
+ df = pd.DataFrame({
9
+ 'col1' : list(range(20)),
10
+ 'col2' : np.random.randn(20),
11
+ 'col3' : np.random.randn(20)
12
+ })
13
+ return df
14
+
15
+
16
+ chart_data = load_data()
17
+
18
+ st.bar_chart(
19
+ chart_data,
20
+ x = 'col1',
21
+ y = ['col2', 'col3'],
22
+ color = ['#FF0000', '#0000FF'] # Optional
23
+ )
pages/charts.graphviz_chart.py CHANGED
@@ -1,7 +1,8 @@
1
- import streamlit as st
2
  import graphviz as graphviz
 
3
 
4
- @st.experimental_memo
 
5
  def load_graph():
6
  # Create a graphlib graph object
7
  graph = graphviz.Digraph()
@@ -20,6 +21,7 @@ def load_graph():
20
  graph.edge("sleep", "runmem")
21
  return graph
22
 
 
23
  graph = load_graph()
24
 
25
  st.graphviz_chart(graph)
 
1
  import graphviz as graphviz
2
+ import streamlit as st
3
 
4
+
5
+ @st.cache_data
6
  def load_graph():
7
  # Create a graphlib graph object
8
  graph = graphviz.Digraph()
21
  graph.edge("sleep", "runmem")
22
  return graph
23
 
24
+
25
  graph = load_graph()
26
 
27
  st.graphviz_chart(graph)
pages/charts.line_chart.py CHANGED
@@ -1,12 +1,16 @@
1
- import streamlit as st
2
- import pandas as pd
3
  import numpy as np
 
 
4
 
5
- @st.experimental_memo
 
6
  def load_data():
7
- df = pd.DataFrame(np.random.randn(20, 3), columns=["a", "b", "c"])
 
 
8
  return df
9
-
 
10
  chart_data = load_data()
11
 
12
  st.line_chart(chart_data)
 
 
1
  import numpy as np
2
+ import pandas as pd
3
+ import streamlit as st
4
 
5
+
6
+ @st.cache_data
7
  def load_data():
8
+ df = pd.DataFrame(
9
+ np.random.randn(20, 3),
10
+ columns = ['a', 'b', 'c'])
11
  return df
12
+
13
+
14
  chart_data = load_data()
15
 
16
  st.line_chart(chart_data)
pages/charts.line_chart1.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pandas as pd
3
+ import streamlit as st
4
+
5
+
6
+ @st.cache_data
7
+ def load_data():
8
+ df = pd.DataFrame({
9
+ 'col1' : np.random.randn(20),
10
+ 'col2' : np.random.randn(20),
11
+ 'col3' : np.random.choice(['A','B','C'], 20)
12
+ })
13
+ return df
14
+
15
+
16
+ chart_data = load_data()
17
+
18
+ st.line_chart(
19
+ chart_data,
20
+ x = 'col1',
21
+ y = 'col2',
22
+ color = 'col3'
23
+ )
pages/charts.line_chart2.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pandas as pd
3
+ import streamlit as st
4
+
5
+
6
+ @st.cache_data
7
+ def load_data():
8
+ df = pd.DataFrame(
9
+ np.random.randn(20, 3),
10
+ columns = ['col1', 'col2', 'col3'])
11
+ return df
12
+
13
+
14
+ chart_data = load_data()
15
+
16
+ st.line_chart(
17
+ chart_data,
18
+ x = 'col1',
19
+ y = ['col2', 'col3'],
20
+ color = ['#FF0000', '#0000FF'] # Optional
21
+ )
pages/charts.map.py CHANGED
@@ -1,14 +1,16 @@
1
- import streamlit as st
2
- import pandas as pd
3
  import numpy as np
 
 
 
4
 
5
- @st.experimental_memo
6
  def load_data():
7
  df = pd.DataFrame(
8
  np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4], columns=["lat", "lon"]
9
  )
10
  return df
11
 
 
12
  df = load_data()
13
 
14
  st.map(df)
 
 
1
  import numpy as np
2
+ import pandas as pd
3
+ import streamlit as st
4
+
5
 
6
+ @st.cache_data
7
  def load_data():
8
  df = pd.DataFrame(
9
  np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4], columns=["lat", "lon"]
10
  )
11
  return df
12
 
13
+
14
  df = load_data()
15
 
16
  st.map(df)
pages/charts.map_color.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import numpy as np
2
+ import pandas as pd
3
+ import streamlit as st
4
+
5
+
6
+ @st.cache_data
7
+ def load_data():
8
+ return pd.DataFrame(
9
+ {
10
+ "col1": np.random.randn(1000) / 50 + 37.76,
11
+ "col2": np.random.randn(1000) / 50 + -122.4,
12
+ "col3": np.random.randn(1000) * 100,
13
+ "col4": np.random.rand(1000, 4).tolist(),
14
+ }
15
+ )
16
+
17
+
18
+ df = load_data()
19
+
20
+ st.map(df, latitude="col1", longitude="col2", size="col3", color="col4")
pages/charts.plotly_chart.py CHANGED
@@ -1,8 +1,9 @@
1
- import streamlit as st
2
- import plotly.figure_factory as ff
3
  import numpy as np
 
 
 
4
 
5
- @st.experimental_memo
6
  def load_data():
7
  # Add histogram data
8
  x1 = np.random.randn(200) - 2
@@ -13,6 +14,7 @@ def load_data():
13
  hist_data = [x1, x2, x3]
14
  return hist_data
15
 
 
16
  hist_data = load_data()
17
 
18
  group_labels = ["Group 1", "Group 2", "Group 3"]
 
 
1
  import numpy as np
2
+ import plotly.figure_factory as ff
3
+ import streamlit as st
4
+
5
 
6
+ @st.cache_data
7
  def load_data():
8
  # Add histogram data
9
  x1 = np.random.randn(200) - 2
14
  hist_data = [x1, x2, x3]
15
  return hist_data
16
 
17
+
18
  hist_data = load_data()
19
 
20
  group_labels = ["Group 1", "Group 2", "Group 3"]
pages/charts.pydeck_chart.py CHANGED
@@ -4,7 +4,7 @@ import pydeck as pdk
4
  import streamlit as st
5
 
6
 
7
- @st.experimental_memo
8
  def load_data():
9
  return pd.DataFrame(
10
  np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4], columns=["lat", "lon"]
4
  import streamlit as st
5
 
6
 
7
+ @st.cache_data
8
  def load_data():
9
  return pd.DataFrame(
10
  np.random.randn(1000, 2) / [50, 50] + [37.76, -122.4], columns=["lat", "lon"]
pages/charts.pyplot.py CHANGED
@@ -1,14 +1,16 @@
1
- import streamlit as st
2
- import numpy as np
3
  import matplotlib.pyplot as plt
 
 
 
4
 
5
- @st.experimental_memo
6
  def load_fig():
7
  arr = np.random.normal(1, 1, size=100)
8
  fig, ax = plt.subplots()
9
  ax.hist(arr, bins=20)
10
  return fig, ax
11
 
 
12
  fig, ax = load_fig()
13
 
14
  st.pyplot(fig)
 
 
1
  import matplotlib.pyplot as plt
2
+ import numpy as np
3
+ import streamlit as st
4
+
5
 
6
+ @st.cache_data
7
  def load_fig():
8
  arr = np.random.normal(1, 1, size=100)
9
  fig, ax = plt.subplots()
10
  ax.hist(arr, bins=20)
11
  return fig, ax
12
 
13
+
14
  fig, ax = load_fig()
15
 
16
  st.pyplot(fig)
pages/charts.vega_lite_chart.py CHANGED
@@ -1,12 +1,14 @@
1
- import streamlit as st
2
- import pandas as pd
3
  import numpy as np
 
 
 
4
 
5
- @st.experimental_memo
6
  def load_data():
7
  df = pd.DataFrame(np.random.randn(200, 3), columns=["a", "b", "c"])
8
  return df
9
 
 
10
  df = load_data()
11
 
12
  st.vega_lite_chart(
 
 
1
  import numpy as np
2
+ import pandas as pd
3
+ import streamlit as st
4
+
5
 
6
+ @st.cache_data
7
  def load_data():
8
  df = pd.DataFrame(np.random.randn(200, 3), columns=["a", "b", "c"])
9
  return df
10
 
11
+
12
  df = load_data()
13
 
14
  st.vega_lite_chart(
pages/chat.echo.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ st.title("Echo Bot")
4
+
5
+ # Initialize chat history
6
+ if "messages" not in st.session_state:
7
+ st.session_state.messages = []
8
+
9
+ # Display chat messages from history on app rerun
10
+ for message in st.session_state.messages:
11
+ with st.chat_message(message["role"]):
12
+ st.markdown(message["content"])
13
+
14
+ # React to user input
15
+ if prompt := st.chat_input("What is up?"):
16
+ # Display user message in chat message container
17
+ st.chat_message("user").markdown(prompt)
18
+ # Add user message to chat history
19
+ st.session_state.messages.append({"role": "user", "content": prompt})
20
+
21
+ response = f"Echo: {prompt}"
22
+ # Display assistant response in chat message container
23
+ with st.chat_message("assistant"):
24
+ st.markdown(response)
25
+ # Add assistant response to chat history
26
+ st.session_state.messages.append({"role": "assistant", "content": response})
pages/chat.input.py ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ prompt = st.chat_input("Say something")
4
+ if prompt:
5
+ st.write(f"User has sent the following prompt: {prompt}")
pages/chat.llm.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import openai
2
+ import streamlit as st
3
+
4
+ st.title("ChatGPT-like clone")
5
+ with st.expander("ℹ️ Disclaimer"):
6
+ st.caption(
7
+ "We appreciate your engagement! Please note, this demo is designed to process a maximum of 10 interactions. Thank you for your understanding."
8
+ )
9
+
10
+ openai.api_key = st.secrets["OPENAI_API_KEY"]
11
+
12
+ if "openai_model" not in st.session_state:
13
+ st.session_state["openai_model"] = "gpt-3.5-turbo"
14
+
15
+ if "messages" not in st.session_state:
16
+ st.session_state.messages = []
17
+
18
+ for message in st.session_state.messages:
19
+ with st.chat_message(message["role"]):
20
+ st.markdown(message["content"])
21
+
22
+ # Maximum allowed messages
23
+ max_messages = (
24
+ 20 # Counting both user and assistant messages, so 10 iterations of conversation
25
+ )
26
+
27
+ if len(st.session_state.messages) >= max_messages:
28
+ st.info(
29
+ """Notice: The maximum message limit for this demo version has been reached. We value your interest!
30
+ We encourage you to experience further interactions by building your own application with instructions
31
+ from Streamlit's [Build conversational apps](https://docs.streamlit.io/knowledge-base/tutorials/build-conversational-apps)
32
+ tutorial. Thank you for your understanding."""
33
+ )
34
+
35
+ else:
36
+ if prompt := st.chat_input("What is up?"):
37
+ st.session_state.messages.append({"role": "user", "content": prompt})
38
+ with st.chat_message("user"):
39
+ st.markdown(prompt)
40
+
41
+ with st.chat_message("assistant"):
42
+ message_placeholder = st.empty()
43
+ full_response = ""
44
+ for response in openai.ChatCompletion.create(
45
+ model=st.session_state["openai_model"],
46
+ messages=[
47
+ {"role": m["role"], "content": m["content"]}
48
+ for m in st.session_state.messages
49
+ ],
50
+ stream=True,
51
+ ):
52
+ full_response += response.choices[0].delta.get("content", "")
53
+ message_placeholder.markdown(full_response + "β–Œ")
54
+ message_placeholder.markdown(full_response)
55
+ st.session_state.messages.append(
56
+ {"role": "assistant", "content": full_response}
57
+ )
pages/chat.message.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ import numpy as np
2
+ import streamlit as st
3
+
4
+ with st.chat_message("user"):
5
+ st.write("Hello πŸ‘‹")
6
+ st.line_chart(np.random.randn(30, 3))
pages/chat.message1.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ import numpy as np
2
+ import streamlit as st
3
+
4
+ message = st.chat_message("assistant")
5
+ message.write("Hello human")
6
+ message.bar_chart(np.random.randn(30, 3))
pages/chat.simple.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import random
2
+ import time
3
+
4
+ import streamlit as st
5
+
6
+ st.title("Simple chat")
7
+
8
+ # Initialize chat history
9
+ if "messages" not in st.session_state:
10
+ st.session_state.messages = []
11
+
12
+ # Display chat messages from history on app rerun
13
+ for message in st.session_state.messages:
14
+ with st.chat_message(message["role"]):
15
+ st.markdown(message["content"])
16
+
17
+ # Accept user input
18
+ if prompt := st.chat_input("What is up?"):
19
+ # Add user message to chat history
20
+ st.session_state.messages.append({"role": "user", "content": prompt})
21
+ # Display user message in chat message container
22
+ with st.chat_message("user"):
23
+ st.markdown(prompt)
24
+
25
+ # Display assistant response in chat message container
26
+ with st.chat_message("assistant"):
27
+ message_placeholder = st.empty()
28
+ full_response = ""
29
+ assistant_response = random.choice(
30
+ [
31
+ "Hello there! How can I assist you today?",
32
+ "Hi, human! Is there anything I can help you with?",
33
+ "Do you need help?",
34
+ ]
35
+ )
36
+ # Simulate stream of response with milliseconds delay
37
+ for chunk in assistant_response.split():
38
+ full_response += chunk + " "
39
+ time.sleep(0.05)
40
+ # Add a blinking cursor to simulate typing
41
+ message_placeholder.markdown(full_response + "β–Œ")
42
+ message_placeholder.markdown(full_response)
43
+ # Add assistant response to chat history
44
+ st.session_state.messages.append({"role": "assistant", "content": full_response})
pages/data.barchart_column.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import streamlit as st
3
+
4
+
5
+ @st.cache_data
6
+ def load_data():
7
+ return pd.DataFrame(
8
+ {
9
+ "sales": [
10
+ [0, 4, 26, 80, 100, 40],
11
+ [80, 20, 80, 35, 40, 100],
12
+ [10, 20, 80, 80, 70, 0],
13
+ [10, 100, 20, 100, 30, 100],
14
+ ],
15
+ }
16
+ )
17
+
18
+
19
+ data_df = load_data()
20
+
21
+ st.data_editor(
22
+ data_df,
23
+ column_config={
24
+ "sales": st.column_config.BarChartColumn(
25
+ "Sales (last 6 months)",
26
+ help="The sales volume in the last 6 months",
27
+ y_min=0,
28
+ y_max=100,
29
+ ),
30
+ },
31
+ hide_index=True,
32
+ )
pages/data.checkbox_column.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import streamlit as st
3
+
4
+
5
+ @st.cache_data
6
+ def load_data():
7
+ return pd.DataFrame(
8
+ {
9
+ "widgets": ["st.selectbox", "st.number_input", "st.text_area", "st.button"],
10
+ "favorite": [True, False, False, True],
11
+ }
12
+ )
13
+
14
+
15
+ data_df = load_data()
16
+
17
+ st.data_editor(
18
+ data_df,
19
+ column_config={
20
+ "favorite": st.column_config.CheckboxColumn(
21
+ "Your favorite?",
22
+ help="Select your **favorite** widgets",
23
+ default=False,
24
+ )
25
+ },
26
+ disabled=["widgets"],
27
+ hide_index=True,
28
+ )
pages/data.column.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import streamlit as st
3
+
4
+
5
+ @st.cache_data
6
+ def load_data():
7
+ return pd.DataFrame(
8
+ {
9
+ "widgets": ["st.selectbox", "st.number_input", "st.text_area", "st.button"],
10
+ }
11
+ )
12
+
13
+
14
+ data_df = load_data()
15
+
16
+ st.data_editor(
17
+ data_df,
18
+ column_config={
19
+ "widgets": st.column_config.Column(
20
+ "Streamlit Widgets",
21
+ help="Streamlit **widget** commands 🎈",
22
+ width="medium",
23
+ required=True,
24
+ )
25
+ },
26
+ hide_index=True,
27
+ num_rows="dynamic",
28
+ )
pages/data.column_config.empty.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+
4
+ df = pd.DataFrame(columns=['name','age','color'])
5
+ colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet']
6
+ config = {
7
+ 'name' : st.column_config.TextColumn('Full Name (required)', width='large', required=True),
8
+ 'age' : st.column_config.NumberColumn('Age (years)', min_value=0, max_value=122),
9
+ 'color' : st.column_config.SelectboxColumn('Favorite Color', options=colors)
10
+ }
11
+
12
+ result = st.data_editor(df, column_config = config, num_rows='dynamic')
13
+
14
+ if st.button('Get results'):
15
+ st.write(result)
pages/data.column_config.py ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import random
2
+ from datetime import date
3
+
4
+ import numpy as np
5
+ import pandas as pd
6
+ import streamlit as st
7
+
8
+ st.set_page_config("Profiles", "πŸ‘€")
9
+
10
+ @st.cache_data
11
+ def get_profile_dataset(number_of_items: int = 100, seed: int = 0) -> pd.DataFrame:
12
+ new_data = []
13
+
14
+ def calculate_age(born):
15
+ today = date.today()
16
+ return (
17
+ today.year - born.year - ((today.month, today.day) < (born.month, born.day))
18
+ )
19
+
20
+ from faker import Faker
21
+
22
+ fake = Faker()
23
+ random.seed(seed)
24
+ Faker.seed(seed)
25
+
26
+ for i in range(number_of_items):
27
+ profile = fake.profile()
28
+ new_data.append(
29
+ {
30
+ "avatar": f"https://picsum.photos/400/200?lock={i}",
31
+ "name": profile["name"],
32
+ "age": calculate_age(profile["birthdate"]),
33
+ "active": random.choice([True, False]),
34
+ "daily_activity": np.random.rand(25),
35
+ "homepage": profile["website"][0],
36
+ "email": profile["mail"],
37
+ "activity": np.random.randint(2, 90, size=25),
38
+ "gender": random.choice(["male", "female", "other", None]),
39
+ "birthdate": profile["birthdate"],
40
+ "status": round(random.uniform(0, 1), 2),
41
+ }
42
+ )
43
+
44
+ profile_df = pd.DataFrame(new_data)
45
+ profile_df["gender"] = profile_df["gender"].astype("category")
46
+ return profile_df
47
+
48
+
49
+ column_configuration = {
50
+ "name": st.column_config.TextColumn(
51
+ "Name", help="The name of the user", max_chars=100
52
+ ),
53
+ "avatar": st.column_config.ImageColumn("Avatar", help="The user's avatar"),
54
+ "active": st.column_config.CheckboxColumn("Is Active?", help="Is the user active?"),
55
+ "homepage": st.column_config.LinkColumn(
56
+ "Homepage", help="The homepage of the user"
57
+ ),
58
+ "gender": st.column_config.SelectboxColumn(
59
+ "Gender", options=["male", "female", "other"]
60
+ ),
61
+ "age": st.column_config.NumberColumn(
62
+ "Age",
63
+ min_value=0,
64
+ max_value=120,
65
+ format="%d years",
66
+ help="The user's age",
67
+ ),
68
+ "activity": st.column_config.LineChartColumn(
69
+ "Activity (1 year)",
70
+ help="The user's activity over the last 1 year",
71
+ width="large",
72
+ y_min=0,
73
+ y_max=100,
74
+ ),
75
+ "daily_activity": st.column_config.BarChartColumn(
76
+ "Activity (daily)",
77
+ help="The user's activity in the last 25 days",
78
+ width="medium",
79
+ y_min=0,
80
+ y_max=1,
81
+ ),
82
+ "status": st.column_config.ProgressColumn(
83
+ "Status", min_value=0, max_value=1, format="%.2f"
84
+ ),
85
+ "birthdate": st.column_config.DateColumn(
86
+ "Birthdate",
87
+ help="The user's birthdate",
88
+ min_value=date(1920, 1, 1),
89
+ ),
90
+ "email": st.column_config.TextColumn(
91
+ "Email",
92
+ help="The user's email address",
93
+ validate="^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$",
94
+ ),
95
+ }
96
+
97
+ st.data_editor(
98
+ get_profile_dataset(),
99
+ column_config=column_configuration,
100
+ use_container_width=True,
101
+ hide_index=True,
102
+ num_rows="fixed",
103
+ )
pages/data.data_editor.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import streamlit as st
3
+
4
+
5
+ @st.cache_data
6
+ def load_data():
7
+ return pd.DataFrame(
8
+ [
9
+ {"command": "st.selectbox", "rating": 4, "is_widget": True},
10
+ {"command": "st.balloons", "rating": 5, "is_widget": False},
11
+ {"command": "st.time_input", "rating": 3, "is_widget": True},
12
+ ]
13
+ )
14
+
15
+
16
+ df = load_data()
17
+ edited_df = st.data_editor(df, use_container_width=True)
18
+
19
+ favorite_command = edited_df.loc[edited_df["rating"].idxmax()]["command"]
20
+ st.markdown(f"Your favorite command is **{favorite_command}** 🎈")
pages/data.data_editor1.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import streamlit as st
3
+
4
+
5
+ @st.cache_data
6
+ def load_data():
7
+ return pd.DataFrame(
8
+ [
9
+ {"command": "st.selectbox", "rating": 4, "is_widget": True},
10
+ {"command": "st.balloons", "rating": 5, "is_widget": False},
11
+ {"command": "st.time_input", "rating": 3, "is_widget": True},
12
+ ]
13
+ )
14
+
15
+
16
+ df = load_data()
17
+ edited_df = st.data_editor(df, num_rows="dynamic", use_container_width=True)
18
+
19
+ favorite_command = edited_df.loc[edited_df["rating"].idxmax()]["command"]
20
+ st.markdown(f"Your favorite command is **{favorite_command}** 🎈")
pages/data.data_editor2.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import streamlit as st
3
+
4
+
5
+ @st.cache_data
6
+ def load_data():
7
+ return pd.DataFrame(
8
+ [
9
+ {"command": "st.selectbox", "rating": 4, "is_widget": True},
10
+ {"command": "st.balloons", "rating": 5, "is_widget": False},
11
+ {"command": "st.time_input", "rating": 3, "is_widget": True},
12
+ ]
13
+ )
14
+
15
+
16
+ df = load_data()
17
+ st.dataframe(df, use_container_width=True)
pages/data.data_editor3.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import streamlit as st
3
+
4
+
5
+ @st.cache_data
6
+ def load_data():
7
+ return pd.DataFrame(
8
+ {
9
+ "name": [
10
+ "Kelly Kelley",
11
+ "Nicole Nguyen MD",
12
+ "Ethan Turner",
13
+ "Todd Burton",
14
+ "Justin Garcia",
15
+ ],
16
+ "age": [75, 9, 39, 28, 89],
17
+ "gender": ["female", "other", "male", "female", "other"],
18
+ "is_active": [True, True, False, True, False],
19
+ "status": [0.71, 0.47, 0.6, 0.26, 0.9],
20
+ "homepage": [
21
+ "http://edwards.com/",
22
+ "https://www.cole.net/",
23
+ "https://www.baird-garner.info/",
24
+ "https://www.porter.biz/",
25
+ "http://ward-romero.org/",
26
+ ],
27
+ }
28
+ )
29
+
30
+
31
+ df = load_data()
32
+ edited_df = st.data_editor(df, use_container_width=True, num_rows="dynamic")
pages/data.data_editor4.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import streamlit as st
3
+
4
+
5
+ @st.cache_data
6
+ def load_data():
7
+ data = {
8
+ "Animal": ["Lion", "Crocodile", "Elephant", "Giraffe", "Penguin"],
9
+ "Weight (kg)": [190, 430, 5000, 800, 4],
10
+ "Is Endangered": [True, True, True, False, False],
11
+ "Classification": ["Mammal", "Reptile", "Mammal", "Mammal", "Bird"],
12
+ "Average Lifespan (years)": [12, 70, 70, 25, 20],
13
+ "Habitat": ["Grassland", "Water", "Savannah", "Savannah", "Antarctica"],
14
+ }
15
+ df = pd.DataFrame(data)
16
+ df["Classification"] = df["Classification"].astype("category")
17
+ df["Habitat"] = df["Habitat"].astype("category")
18
+ return df
19
+
20
+
21
+ df = load_data()
22
+
23
+ st.data_editor(df, key="data_editor", num_rows="dynamic")
24
+ st.write("Here's the session state:")
25
+ st.write(st.session_state["data_editor"])
pages/data.data_editor_config.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import streamlit as st
3
+
4
+
5
+ @st.cache_data
6
+ def load_data():
7
+ return pd.DataFrame(
8
+ [
9
+ {"command": "st.selectbox", "rating": 4, "is_widget": True},
10
+ {"command": "st.balloons", "rating": 5, "is_widget": False},
11
+ {"command": "st.time_input", "rating": 3, "is_widget": True},
12
+ ]
13
+ )
14
+
15
+
16
+ df = load_data()
17
+
18
+ edited_df = st.data_editor(
19
+ df,
20
+ column_config={
21
+ "command": "Streamlit Command",
22
+ "rating": st.column_config.NumberColumn(
23
+ "Your rating",
24
+ help="How much do you like this command (1-5)?",
25
+ min_value=1,
26
+ max_value=5,
27
+ step=1,
28
+ format="%d ⭐",
29
+ ),
30
+ "is_widget": "Widget ?",
31
+ },
32
+ disabled=["command", "is_widget"],
33
+ hide_index=True,
34
+ )
35
+
36
+ favorite_command = edited_df.loc[edited_df["rating"].idxmax()]["command"]
37
+ st.markdown(f"Your favorite command is **{favorite_command}** 🎈")
pages/data.dataframe.py CHANGED
@@ -1,12 +1,16 @@
1
- import streamlit as st
2
- import pandas as pd
3
  import numpy as np
 
 
 
4
 
5
- @st.experimental_memo
6
  def load_data():
7
- df = pd.DataFrame(np.random.randn(50, 20), columns=("col %d" % i for i in range(20)))
 
 
8
  return df
9
 
 
10
  df = load_data()
11
 
12
  st.dataframe(df) # Same as st.write(df)
 
 
1
  import numpy as np
2
+ import pandas as pd
3
+ import streamlit as st
4
+
5
 
6
+ @st.cache_data
7
  def load_data():
8
+ df = pd.DataFrame(
9
+ np.random.randn(50, 20), columns=("col %d" % i for i in range(20))
10
+ )
11
  return df
12
 
13
+
14
  df = load_data()
15
 
16
  st.dataframe(df) # Same as st.write(df)
pages/data.dataframe1.py CHANGED
@@ -1,12 +1,16 @@
1
- import streamlit as st
2
- import pandas as pd
3
  import numpy as np
 
 
 
4
 
5
- @st.experimental_memo
6
  def load_data():
7
- df = pd.DataFrame(np.random.randn(10, 20), columns=("col %d" % i for i in range(20)))
 
 
8
  return df
9
 
 
10
  df = load_data()
11
 
12
- st.dataframe(df.style.highlight_max(axis=0))
 
 
1
  import numpy as np
2
+ import pandas as pd
3
+ import streamlit as st
4
+
5
 
6
+ @st.cache_data
7
  def load_data():
8
+ df = pd.DataFrame(
9
+ np.random.randn(10, 20), columns=("col %d" % i for i in range(20))
10
+ )
11
  return df
12
 
13
+
14
  df = load_data()
15
 
16
+ st.dataframe(df.style.highlight_max(axis=0))
pages/data.dataframe2.py CHANGED
@@ -3,7 +3,7 @@ import streamlit as st
3
 
4
 
5
  # Cache the dataframe so it's only loaded once
6
- @st.experimental_memo
7
  def load_data():
8
  return pd.DataFrame(
9
  {
3
 
4
 
5
  # Cache the dataframe so it's only loaded once
6
+ @st.cache_data
7
  def load_data():
8
  return pd.DataFrame(
9
  {
pages/data.dataframe_config.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import random
2
+
3
+ import pandas as pd
4
+ import streamlit as st
5
+
6
+
7
+ @st.cache_data
8
+ def load_data():
9
+ return pd.DataFrame(
10
+ {
11
+ "name": ["Roadmap", "Extras", "Issues"],
12
+ "url": [
13
+ "https://roadmap.streamlit.app",
14
+ "https://extras.streamlit.app",
15
+ "https://issues.streamlit.app",
16
+ ],
17
+ "stars": [random.randint(0, 1000) for _ in range(3)],
18
+ "views_history": [
19
+ [random.randint(0, 5000) for _ in range(30)] for _ in range(3)
20
+ ],
21
+ }
22
+ )
23
+
24
+
25
+ df = load_data()
26
+
27
+ st.dataframe(
28
+ df,
29
+ column_config={
30
+ "name": "App name",
31
+ "stars": st.column_config.NumberColumn(
32
+ "Github Stars",
33
+ help="Number of stars on GitHub",
34
+ format="%d ⭐",
35
+ ),
36
+ "url": st.column_config.LinkColumn("App URL"),
37
+ "views_history": st.column_config.LineChartColumn(
38
+ "Views (past 30 days)", y_min=0, y_max=5000
39
+ ),
40
+ },
41
+ hide_index=True,
42
+ )
pages/data.date_column.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import date
2
+
3
+ import pandas as pd
4
+ import streamlit as st
5
+
6
+
7
+ @st.cache_data
8
+ def load_data():
9
+ return pd.DataFrame(
10
+ {
11
+ "birthday": [
12
+ date(1980, 1, 1),
13
+ date(1990, 5, 3),
14
+ date(1974, 5, 19),
15
+ date(2001, 8, 17),
16
+ ]
17
+ }
18
+ )
19
+
20
+
21
+ data_df = load_data()
22
+
23
+ st.data_editor(
24
+ data_df,
25
+ column_config={
26
+ "birthday": st.column_config.DateColumn(
27
+ "Birthday",
28
+ min_value=date(1900, 1, 1),
29
+ max_value=date(2005, 1, 1),
30
+ format="DD.MM.YYYY",
31
+ step=1,
32
+ ),
33
+ },
34
+ hide_index=True,
35
+ )
pages/data.datetime_column.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import datetime
2
+
3
+ import pandas as pd
4
+ import streamlit as st
5
+
6
+
7
+ @st.cache_data
8
+ def load_data():
9
+ return pd.DataFrame(
10
+ {
11
+ "appointment": [
12
+ datetime(2024, 2, 5, 12, 30),
13
+ datetime(2023, 11, 10, 18, 0),
14
+ datetime(2024, 3, 11, 20, 10),
15
+ datetime(2023, 9, 12, 3, 0),
16
+ ]
17
+ }
18
+ )
19
+
20
+
21
+ data_df = load_data()
22
+
23
+ st.data_editor(
24
+ data_df,
25
+ column_config={
26
+ "appointment": st.column_config.DatetimeColumn(
27
+ "Appointment",
28
+ min_value=datetime(2023, 6, 1),
29
+ max_value=datetime(2025, 1, 1),
30
+ format="D MMM YYYY, h:mm a",
31
+ step=60,
32
+ ),
33
+ },
34
+ hide_index=True,
35
+ )
pages/data.image_column.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import streamlit as st
3
+
4
+
5
+ @st.cache_data
6
+ def load_data():
7
+ return pd.DataFrame(
8
+ {
9
+ "apps": [
10
+ "https://storage.googleapis.com/s4a-prod-share-preview/default/st_app_screenshot_image/5435b8cb-6c6c-490b-9608-799b543655d3/Home_Page.png",
11
+ "https://storage.googleapis.com/s4a-prod-share-preview/default/st_app_screenshot_image/ef9a7627-13f2-47e5-8f65-3f69bb38a5c2/Home_Page.png",
12
+ "https://storage.googleapis.com/s4a-prod-share-preview/default/st_app_screenshot_image/31b99099-8eae-4ff8-aa89-042895ed3843/Home_Page.png",
13
+ "https://storage.googleapis.com/s4a-prod-share-preview/default/st_app_screenshot_image/6a399b09-241e-4ae7-a31f-7640dc1d181e/Home_Page.png",
14
+ ],
15
+ }
16
+ )
17
+
18
+
19
+ data_df = load_data()
20
+
21
+ st.data_editor(
22
+ data_df,
23
+ column_config={
24
+ "apps": st.column_config.ImageColumn(
25
+ "Preview Image", help="Streamlit app preview screenshots"
26
+ )
27
+ },
28
+ hide_index=True,
29
+ )
pages/data.linechart_column.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import streamlit as st
3
+
4
+
5
+ @st.cache_data
6
+ def load_data():
7
+ return pd.DataFrame(
8
+ {
9
+ "sales": [
10
+ [0, 4, 26, 80, 100, 40],
11
+ [80, 20, 80, 35, 40, 100],
12
+ [10, 20, 80, 80, 70, 0],
13
+ [10, 100, 20, 100, 30, 100],
14
+ ],
15
+ }
16
+ )
17
+
18
+
19
+ data_df = load_data()
20
+
21
+ st.data_editor(
22
+ data_df,
23
+ column_config={
24
+ "sales": st.column_config.LineChartColumn(
25
+ "Sales (last 6 months)",
26
+ width="medium",
27
+ help="The sales volume in the last 6 months",
28
+ y_min=0,
29
+ y_max=100,
30
+ ),
31
+ },
32
+ hide_index=True,
33
+ )
pages/data.link_column.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import streamlit as st
3
+
4
+
5
+ @st.cache_data
6
+ def load_data():
7
+ return pd.DataFrame(
8
+ {
9
+ "apps": [
10
+ "https://roadmap.streamlit.app",
11
+ "https://extras.streamlit.app",
12
+ "https://issues.streamlit.app",
13
+ "https://30days.streamlit.app",
14
+ ],
15
+ }
16
+ )
17
+
18
+
19
+ data_df = load_data()
20
+
21
+ st.data_editor(
22
+ data_df,
23
+ column_config={
24
+ "apps": st.column_config.LinkColumn(
25
+ "Trending apps",
26
+ help="The top trending Streamlit apps",
27
+ validate="^https://[a-z]+\.streamlit\.app$",
28
+ max_chars=100,
29
+ )
30
+ },
31
+ hide_index=True,
32
+ )
pages/data.list_column.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import streamlit as st
3
+
4
+
5
+ @st.cache_data
6
+ def load_data():
7
+ return pd.DataFrame(
8
+ {
9
+ "sales": [
10
+ [0, 4, 26, 80, 100, 40],
11
+ [80, 20, 80, 35, 40, 100],
12
+ [10, 20, 80, 80, 70, 0],
13
+ [10, 100, 20, 100, 30, 100],
14
+ ],
15
+ }
16
+ )
17
+
18
+
19
+ data_df = load_data()
20
+
21
+ st.data_editor(
22
+ data_df,
23
+ column_config={
24
+ "sales": st.column_config.ListColumn(
25
+ "Sales (last 6 months)",
26
+ help="The sales volume in the last 6 months",
27
+ width="medium",
28
+ ),
29
+ },
30
+ hide_index=True,
31
+ )
pages/data.number_column.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import streamlit as st
3
+
4
+
5
+ @st.cache_data
6
+ def load_data():
7
+ return pd.DataFrame(
8
+ {
9
+ "price": [20, 950, 250, 500],
10
+ }
11
+ )
12
+
13
+
14
+ data_df = load_data()
15
+
16
+ st.data_editor(
17
+ data_df,
18
+ column_config={
19
+ "price": st.column_config.NumberColumn(
20
+ "Price (in USD)",
21
+ help="The price of the product in USD",
22
+ min_value=0,
23
+ max_value=1000,
24
+ step=1,
25
+ format="$%d",
26
+ )
27
+ },
28
+ hide_index=True,
29
+ )
pages/data.progress_column.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import streamlit as st
3
+
4
+
5
+ @st.cache_data
6
+ def load_data():
7
+ return pd.DataFrame(
8
+ {
9
+ "sales": [200, 550, 1000, 80],
10
+ }
11
+ )
12
+
13
+
14
+ data_df = load_data()
15
+
16
+ st.data_editor(
17
+ data_df,
18
+ column_config={
19
+ "sales": st.column_config.ProgressColumn(
20
+ "Sales volume",
21
+ help="The sales volume in USD",
22
+ format="$%f",
23
+ min_value=0,
24
+ max_value=1000,
25
+ ),
26
+ },
27
+ hide_index=True,
28
+ )
pages/data.selectbox_column.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import streamlit as st
3
+
4
+
5
+ @st.cache_data
6
+ def load_data():
7
+ return pd.DataFrame(
8
+ {
9
+ "category": [
10
+ "πŸ“Š Data Exploration",
11
+ "πŸ“ˆ Data Visualization",
12
+ "πŸ€– LLM",
13
+ "πŸ“Š Data Exploration",
14
+ ],
15
+ }
16
+ )
17
+
18
+
19
+ data_df = load_data()
20
+
21
+ st.data_editor(
22
+ data_df,
23
+ column_config={
24
+ "category": st.column_config.SelectboxColumn(
25
+ "App Category",
26
+ help="The category of the app",
27
+ width="medium",
28
+ options=[
29
+ "πŸ“Š Data Exploration",
30
+ "πŸ“ˆ Data Visualization",
31
+ "πŸ€– LLM",
32
+ ],
33
+ required=True,
34
+ )
35
+ },
36
+ hide_index=True,
37
+ )
pages/data.table.py CHANGED
@@ -1,12 +1,14 @@
1
- import streamlit as st
2
- import pandas as pd
3
  import numpy as np
 
 
 
4
 
5
- @st.experimental_memo
6
  def load_data():
7
  df = pd.DataFrame(np.random.randn(10, 5), columns=("col %d" % i for i in range(5)))
8
  return df
9
 
 
10
  df = load_data()
11
 
12
  st.table(df)
 
 
1
  import numpy as np
2
+ import pandas as pd
3
+ import streamlit as st
4
+
5
 
6
+ @st.cache_data
7
  def load_data():
8
  df = pd.DataFrame(np.random.randn(10, 5), columns=("col %d" % i for i in range(5)))
9
  return df
10
 
11
+
12
  df = load_data()
13
 
14
  st.table(df)
pages/data.text_column.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import streamlit as st
3
+
4
+
5
+ @st.cache_data
6
+ def load_data():
7
+ return pd.DataFrame(
8
+ {
9
+ "widgets": ["st.selectbox", "st.number_input", "st.text_area", "st.button"],
10
+ }
11
+ )
12
+
13
+
14
+ data_df = load_data()
15
+
16
+ st.data_editor(
17
+ data_df,
18
+ column_config={
19
+ "widgets": st.column_config.TextColumn(
20
+ "Widgets",
21
+ help="Streamlit **widget** commands 🎈",
22
+ default="st.",
23
+ max_chars=50,
24
+ validate="^st\.[a-z_]+$",
25
+ )
26
+ },
27
+ hide_index=True,
28
+ )
pages/data.time_column.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from datetime import time
2
+
3
+ import pandas as pd
4
+ import streamlit as st
5
+
6
+
7
+ @st.cache_data
8
+ def load_data():
9
+ return pd.DataFrame(
10
+ {
11
+ "appointment": [
12
+ time(12, 30),
13
+ time(18, 0),
14
+ time(9, 10),
15
+ time(16, 25),
16
+ ]
17
+ }
18
+ )
19
+
20
+
21
+ data_df = load_data()
22
+
23
+ st.data_editor(
24
+ data_df,
25
+ column_config={
26
+ "appointment": st.column_config.TimeColumn(
27
+ "Appointment",
28
+ min_value=time(8, 0, 0),
29
+ max_value=time(19, 0, 0),
30
+ format="hh:mm a",
31
+ step=60,
32
+ ),
33
+ },
34
+ hide_index=True,
35
+ )