当前位置:   article > 正文

python Streamlit 库示例

streamlit
# Pycharm V2021 
# 解释器 Python 3.7 D:\ProgramData\Anaconda3\python.exe
# -*- coding:utf-8
# author :RainChang 
# 2021/10/28,13:42
# 操作说明:http://cw.hubwiz.com/card/c/streamlit-manual/
# 示例来源:https://blog.csdn.net/qq_44747847/article/details/116462041?spm=1001.2101.3001.6650.5&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-5.no_search_link&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-5.no_search_link
# 在Terminal 运行Streamlit run  filename.py


import time

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import streamlit as st
from PIL import Image
import altair as alt

st.title("This is my first app")
st.write("hello")
st.write("Here's our first attempt at using data to create a table:")

df = pd.DataFrame({
    'first column': [5, 6, 7, 8],
    'second column': [50, 60, 70, 80]
})

st.write(pd.DataFrame({
    'first column': [1, 2, 3, 4],
    'second column': [10, 20, 30, 40]
}))
# 其中df定义的位置,并不影响最后的输出位置!
# df

# 绘制图表
# 折线图
chart_data = pd.DataFrame(
    np.random.randn(20, 3),
    columns=['a', 'b', 'c'])

st.line_chart(chart_data)

# 区域图的可视化
# “streamlit”中的“area_chart”方法显示区域图,方法原型和折线图用到的方法一致,所以这里就不做过多的赘述,例如下面的代码

chart_data =
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/361908
推荐阅读
相关标签
  

闽ICP备14008679号