streamlit

安装streamlit模块

python3 -V
Python 3.6.8
pip3 install --upgrade pip
pip3 install streamlit

web_app.py

import streamlit as st
import pandas as pd
import numpy as np

st.title('pandas.DataFrame')
st.write(
    pd.DataFrame({
        '语言1': ['java', 'python', 'scala', 'c#', 'c++', 'go'],
        '表现1': ['A', 'A', 'A', 'A', 'A', 'A'],
        '难度1': ['5', '5', '5', '5', '5', '5'],
        '语言2': ['java', 'python', 'scala', 'c#', 'c++', 'go'],
        '表现2': ['A', 'A', 'A', 'A', 'A', 'A'],
        '难度2': ['5', '5', '5', '5', '5', '5'],
        '语言3': ['java', 'python', 'scala', 'c#', 'c++', 'go'],
        '表现3': ['A', 'A', 'A', 'A', 'A', 'A'],
        '难度3': ['5', '5', '5', '5', '5', '5']
    })
)

st.latex(r'''
    a + ar + a r^2 + a r^3 + \cdots + a r^{n-1} =
    \sum_{k=0}^{n-1} ar^k =
    a \left(\frac{1-r^{n}}{1-r}\right)
    ''')

st.line_chart(pd.DataFrame(
    np.random.randn(20, 3),
    columns=['a', 'b', 'c'])
)

运行

streamlit run web_app.py

  You can now view your Streamlit app in your browser.

  Network URL: http://10.0.0.12:8501

streamlit_第1张图片

markdown.py

import streamlit as st
import pandas as pd
import numpy as np

st.set_page_config(
    page_title="my markdown",
)

st.write("一起体验streamlit!")
st.sidebar.success("markdown示例导航")
st.markdown(
"""
# 标题1
## 标题2
### 标题3
#### 标题4
##### 标题5
\`\`\`python
score = int(input("score:"))
if score > 90:
    print("A")
elif score > 80:
    print("B")
elif score > 70:
    print("C")
elif score > 50:
    print("D")
else:
    print("go")
\`\`\`
[https://docs.streamlit.io/library/get-started/main-concepts](https://docs.streamlit.io/library/get-started/main-concepts)
"""
)

streamlit_第2张图片

你可能感兴趣的:(python,pandas,python)