Spaces:
Runtime error
Runtime error
Download utils.py from friedeggy/Robots_2_Data: direct link, hf CLI and curl.
- Browser
- Download file 1.46 kB
-
https://huggingface.co/spaces/friedeggy/Robots_2_Data/resolve/main/utils.py
- Command line
-
hf download hf://spaces/friedeggy/Robots_2_Data/utils.py
-
curl -L -o utils.py https://huggingface.co/spaces/friedeggy/Robots_2_Data/resolve/main/utils.py
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 | |