If you are using a Taipy Table, you can first put the "filter" property to True. It allows filtering the data on the different columns.
If this is enough for some reason, you can filter with some code. the code below is a simple example of code to filter dates and string.
from taipy.gui import Gui
import pandas as pd
import datetime as dt
import numpy as np
# this function will filter the dataframe
# we can have multiple functions to filter it depending on the
# visual elements that have been changed to be more efficient
def filter_data(data, input_str, start_date, end_date):
index = (data['Date'] > np.datetime64(start_date)) &\
(data['Date'] < np.datetime64(end_date)) &\
(data["Value"].apply(lambda x: input_str in x))
filtered_data = data[index]
return filtered_data
# processing of a DataFrame (two columns: Date, Value)
original_data = pd.read_csv("graph_examples/airline_passengers.csv")
original_data['Date'] = pd.to_datetime(original_data['Date'])
original_data['Value'] = original_data['Value'].astype(str)
# Initialization of variables of the GUI
input_for_filter = ""
start_date = dt.datetime(1950,1,1)
end_date = dt.datetime(1960,1,1)
filtered_data = filter_data(original_data,
input_for_filter,
start_date,
end_date)
# simple Markdown
md = """
<|{input_for_filter}|input|on_change=on_changer_filter|>
<|{start_date}|date|on_change=on_changer_filter|> <|{end_date}|date|on_change=on_changer_filter|>
<|{filtered_data}|table|>
"""
# function called by the GUI to filter the dataframe when a change is being done
# on visual elements
def on_changer_filter(state):
state.filtered_data = filter_data(original_data,
state.input_for_filter,
state.start_date,
state.end_date)
# GUI running
Gui(md).run()
I hope this will help you to create your own filtering.