Robots_2_Data / utils.py
AshWu03
Adds backend functionality
7f49828
Raw History Blame Contribute Delete
1.46 kB
import gradio as gr
import pandas as pd
OG_DF = pd.read_csv("All_Robots_Combined_Labeled.csv")
FILTER_DF = pd.read_csv("All_Robots_Combined_Labeled.csv")
def robot(show, df, col_name):
"""
Determines whether robot 1 should be shown in the data frame
args:
show - Boolean
Determines whether robot 1 should be shown in the CSV file or not
robot_num - int
The number of the robot the filter is applying to
returns:
nothing
"""
if not show and col_name in df:
df.drop(col_name)
elif show and col_name not in df:
df.insert(OG_DF[col_name])
return df
def row_filter(show, val, col, df):
"Filter out values in specified column"
"TODO: Add rest of func definition"
if show:
b = OG_DF[OG_DF[col] == val]
df = pd.concat([df, b])
elif not show:
df = df[df[col] != val]
return df
def select_all():
"Select all options in the filter and restore the dataframe"
return OG_DF, *[gr.update(value=True)] * 21
def clear_all():
"Deselect all options in the filter and remove all rows in the dataframe"
return pd.DataFrame, *[gr.update(value=True)] * 21
def apply():
"""
Applies the filter dataframe to the dataframe in the frontend
Returns:
Filter dataframe
"""
return FILTER_DF