streamlit

Форк
0
/
st_arrow_new_features.py 
66 строк · 1.6 Кб
1
# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022-2024)
2
#
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
# you may not use this file except in compliance with the License.
5
# You may obtain a copy of the License at
6
#
7
#     http://www.apache.org/licenses/LICENSE-2.0
8
#
9
# Unless required by applicable law or agreed to in writing, software
10
# distributed under the License is distributed on an "AS IS" BASIS,
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
# See the License for the specific language governing permissions and
13
# limitations under the License.
14

15
import pandas as pd
16

17
import streamlit as st
18

19
"## Table Caption"
20
df = pd.DataFrame([["foo", 100], ["bar", 200]])
21
styler = df.style.set_caption("The caption")
22
st.table(styler)
23

24
"## CategoricalIndex"
25
df = pd.DataFrame(
26
    [["foo", 100], ["bar", 200]],
27
    index=pd.CategoricalIndex([1, 2]),
28
)
29
st.table(df)
30

31
"## IntervalIndex"
32
df = pd.DataFrame(
33
    [["foo", 100], ["bar", 200]],
34
    index=pd.interval_range(start=0, end=2),
35
)
36
st.table(df)
37

38
"## MultiIndex Styler"
39
df = pd.DataFrame(
40
    [["foo", 100], ["bar", 200]],
41
    index=[["a", "b"], [1, 2]],
42
)
43
styler = df.style.highlight_max()
44
st.table(styler)
45

46
"## MultiIndex `add_rows()`"
47
df1 = pd.DataFrame(
48
    [["foo", 100], ["bar", 200]],
49
    index=[["a", "b"], [1, 2]],
50
)
51
df2 = pd.DataFrame(
52
    [["baz", 300], ["qux", 400]],
53
    index=[["c", "d"], [3, 4]],
54
)
55
table = st.table(df1)
56
table.add_rows(df2)
57

58
"## RangeIndex `step`"
59
df = pd.DataFrame(
60
    [["foo", 100], ["bar", 200]], index=pd.RangeIndex(start=10, stop=30, step=10)
61
)
62
st.table(df)
63

64
"## `Pandas.NaT`"
65
df = pd.DataFrame([[pd.NaT, 100], [pd.NaT, 200]])
66
st.table(df)
67

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.