Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion python/api-examples-source/charts.area_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

@st.cache_data
def load_data():
df = pd.DataFrame(np.random.randn(20, 3), columns=["a", "b", "c"])
df = pd.DataFrame(
np.random.randn(20, 3),
columns = ['a', 'b', 'c'])
return df


Expand Down
23 changes: 23 additions & 0 deletions python/api-examples-source/charts.area_chart1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import numpy as np
import pandas as pd
import streamlit as st


@st.cache_data
def load_data():
df = pd.DataFrame({
'col1' : np.random.randn(20),
'col2' : np.random.randn(20),
'col3' : np.random.choice(['A','B','C'], 20)
})
return df


chart_data = load_data()

st.area_chart(
chart_data,
x = 'col1',
y = 'col2',
color = 'col3'
)
21 changes: 21 additions & 0 deletions python/api-examples-source/charts.area_chart2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import numpy as np
import pandas as pd
import streamlit as st


@st.cache_data
def load_data():
df = pd.DataFrame(
np.random.randn(20, 3),
columns = ['col1', 'col2', 'col3'])
return df


chart_data = load_data()

st.area_chart(
chart_data,
x = 'col1',
y = ['col2', 'col3'],
color = ['#FF0000', '#0000FF'] # Optional
)
4 changes: 3 additions & 1 deletion python/api-examples-source/charts.bar_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

@st.cache_data
def load_data():
df = pd.DataFrame(np.random.randn(50, 3), columns=["a", "b", "c"])
df = pd.DataFrame(
np.random.randn(50, 3),
columns = ["a", "b", "c"])
return df


Expand Down
23 changes: 23 additions & 0 deletions python/api-examples-source/charts.bar_chart1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import numpy as np
import pandas as pd
import streamlit as st


@st.cache_data
def load_data():
df = pd.DataFrame({
'col1' : list(range(20))*3,
'col2' : np.random.randn(60),
'col3' : ['A']*20 + ['B']*20 + ['C']*20
})
return df


chart_data = load_data()

st.bar_chart(
chart_data,
x = 'col1',
y = 'col2',
color = 'col3'
)
23 changes: 23 additions & 0 deletions python/api-examples-source/charts.bar_chart2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import numpy as np
import pandas as pd
import streamlit as st


@st.cache_data
def load_data():
df = pd.DataFrame({
'col1' : list(range(20)),
'col2' : np.random.randn(20),
'col3' : np.random.randn(20)
})
return df


chart_data = load_data()

st.bar_chart(
chart_data,
x = 'col1',
y = ['col2', 'col3'],
color = ['#FF0000', '#0000FF'] # Optional
)
4 changes: 3 additions & 1 deletion python/api-examples-source/charts.line_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

@st.cache_data
def load_data():
df = pd.DataFrame(np.random.randn(20, 3), columns=["a", "b", "c"])
df = pd.DataFrame(
np.random.randn(20, 3),
columns = ['a', 'b', 'c'])
return df


Expand Down
23 changes: 23 additions & 0 deletions python/api-examples-source/charts.line_chart1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import numpy as np
import pandas as pd
import streamlit as st


@st.cache_data
def load_data():
df = pd.DataFrame({
'col1' : np.random.randn(20),
'col2' : np.random.randn(20),
'col3' : np.random.choice(['A','B','C'], 20)
})
return df


chart_data = load_data()

st.line_chart(
chart_data,
x = 'col1',
y = 'col2',
color = 'col3'
)
21 changes: 21 additions & 0 deletions python/api-examples-source/charts.line_chart2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import numpy as np
import pandas as pd
import streamlit as st


@st.cache_data
def load_data():
df = pd.DataFrame(
np.random.randn(20, 3),
columns = ['col1', 'col2', 'col3'])
return df


chart_data = load_data()

st.line_chart(
chart_data,
x = 'col1',
y = ['col2', 'col3'],
color = ['#FF0000', '#0000FF'] # Optional
)
2 changes: 1 addition & 1 deletion python/api-examples-source/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ altair==4.2.0
pydeck==0.8.0
Faker==19.1.0
openai==0.27.8
streamlit==1.25.0
streamlit-nightly
10 changes: 10 additions & 0 deletions python/api-examples-source/status.status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import time
import streamlit as st

with st.status("Downloading data..."):
st.write("Searching for data...")
time.sleep(2)
st.write("Found URL.")
time.sleep(1)
st.write("Downloading data...")
time.sleep(1)
11 changes: 11 additions & 0 deletions python/api-examples-source/status.status1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import time
import streamlit as st

with st.status("Downloading data...", expanded=True) as status:
st.write("Searching for data...")
time.sleep(2)
st.write("Found URL.")
time.sleep(1)
st.write("Downloading data...")
time.sleep(1)
status.update(label="Download complete!", state="complete", expanded=False)
3 changes: 2 additions & 1 deletion python/api-examples-source/text.header.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import streamlit as st

st.header("This is a header")
st.header('This is a header with a divider', divider='rainbow')
st.header('_Streamlit_ is :blue[cool] :sunglasses:')
14 changes: 13 additions & 1 deletion python/api-examples-source/text.markdown.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
import streamlit as st

st.markdown("Streamlit is **_really_ cool**.")
st.markdown("*Streamlit* is **really** ***cool***.")
st.markdown("""
:red[Streamlit] :orange[can] :green[write] :blue[text] :violet[in]
:gray[pretty] :rainbow[colors].""")
st.markdown("Here's a bouquet —\
:tulip::cherry_blossom::rose::hibiscus::sunflower::blossom:")

multi = '''If you end a line with two spaces,
a soft return is used for the next line.

Two (or more) newline characters in a row will result in a hard return.
'''
st.markdown(multi)
12 changes: 12 additions & 0 deletions python/api-examples-source/text.markdown1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import streamlit as st

md = st.text_area('Type in your markdown string (without outer quotes)',
"Happy Streamlit-ing! :balloon:")

st.code(f"""
import streamlit as st

st.markdown('''{md}''')
""")

st.markdown(md)
3 changes: 2 additions & 1 deletion python/api-examples-source/text.subheader.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import streamlit as st

st.subheader("This is a subheader")
st.subheader('This is a subheader with a divider', divider='rainbow')
st.subheader('_Streamlit_ is :blue[cool] :sunglasses:')
3 changes: 2 additions & 1 deletion python/api-examples-source/text.title.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import streamlit as st

st.title("This is a title")
st.title('This is a title')
st.title('_Streamlit_ is :blue[cool] :sunglasses:')
6 changes: 6 additions & 0 deletions python/api-examples-source/widget.toggle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import streamlit as st

on = st.toggle('Activate feature')

if on:
st.write('Feature activated!')
2 changes: 2 additions & 0 deletions python/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import docstring_parser
import streamlit
import streamlit.components.v1 as components
from streamlit.elements.lib.mutable_status_container import StatusContainer
from docutils.core import publish_parts
from docutils.parsers.rst import directives
from numpydoc.docscrape import NumpyDocString
Expand Down Expand Up @@ -489,6 +490,7 @@ def get_streamlit_docstring_dict():
],
components: ["streamlit.components.v1", "st.components.v1"],
streamlit._DeltaGenerator: ["DeltaGenerator", "element"],
StatusContainer: ["StatusContainer", "StatusContainer"]
}

module_docstring_dict = {}
Expand Down