File tree Expand file tree Collapse file tree 1 file changed +15
-17
lines changed Expand file tree Collapse file tree 1 file changed +15
-17
lines changed Original file line number Diff line number Diff line change 1
- import numpy as np
2
- import pandas as pd
3
1
import streamlit as st
4
- from streamlit_condition_tree import condition_tree , config_from_dataframe
2
+ import pandas as pd
5
3
6
- df = pd .read_csv (
7
- 'https://drive.google.com/uc?id=1phaHg9objxK2MwaZmSUZAKQ8kVqlgng4&export=download' ,
8
- index_col = 0 ,
9
- parse_dates = ['Date of birth' ],
10
- date_format = '%Y-%m-%d' )
11
- df ['Age' ] = ((pd .Timestamp .today () - df ['Date of birth' ]).dt .days / 365 ).astype (int )
12
- df ['Sex' ] = pd .Categorical (df ['Sex' ])
13
- df ['Likes tomatoes' ] = np .random .randint (2 , size = df .shape [0 ]).astype (bool )
4
+ from streamlit_condition_tree import condition_tree , config_from_dataframe
14
5
15
- st .dataframe (df )
6
+ # Initial dataframe
7
+ df = pd .DataFrame ({
8
+ 'First Name' : ['Georges' , 'Alfred' ],
9
+ 'Age' : [45 , 98 ],
10
+ 'Favorite Color' : ['Green' , 'Red' ],
11
+ 'Like Tomatoes' : [True , False ]
12
+ })
16
13
14
+ # Basic field configuration from dataframe
17
15
config = config_from_dataframe (df )
18
16
19
- return_val = condition_tree (
17
+ # Condition tree
18
+ query_string = condition_tree (
20
19
config ,
20
+ always_show_buttons = True
21
21
)
22
22
23
- st .code (return_val )
24
-
25
- df = df .query (return_val )
26
- st .dataframe (df )
23
+ # Filtered dataframe
24
+ df = df .query (query_string )
You can’t perform that action at this time.
0 commit comments