Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ import gradio as gr
|
|
| 4 |
def group_names(file, members_per_group, fixed_groups_input):
|
| 5 |
# Read the CSV file
|
| 6 |
df = pd.read_csv(file.name, encoding='utf-8')
|
| 7 |
-
|
| 8 |
# Parse fixed groups input
|
| 9 |
fixed_groups = [group.strip() for group in fixed_groups_input.split(';') if group.strip()]
|
| 10 |
fixed_groups_df_list = []
|
|
@@ -21,7 +21,7 @@ def group_names(file, members_per_group, fixed_groups_input):
|
|
| 21 |
|
| 22 |
# Shuffle the remaining DataFrame
|
| 23 |
remaining_df = remaining_df.sample(frac=1).reset_index(drop=True)
|
| 24 |
-
|
| 25 |
# Adjusting fixed groups to include additional members if they're under the specified group size
|
| 26 |
for i, group_df in enumerate(fixed_groups_df_list):
|
| 27 |
while len(group_df) < members_per_group and not remaining_df.empty:
|
|
@@ -41,7 +41,7 @@ def group_names(file, members_per_group, fixed_groups_input):
|
|
| 41 |
names = ', '.join(group['Names'].tolist())
|
| 42 |
grouped_data.append({'Group': group_name, 'Members': names})
|
| 43 |
grouped_df = pd.DataFrame(grouped_data)
|
| 44 |
-
|
| 45 |
return grouped_df
|
| 46 |
|
| 47 |
def main_interface(file, members_per_group, fixed_groups_input):
|
|
@@ -62,4 +62,4 @@ iface = gr.Interface(
|
|
| 62 |
allow_flagging="never"
|
| 63 |
)
|
| 64 |
|
| 65 |
-
iface.launch()
|
|
|
|
| 4 |
def group_names(file, members_per_group, fixed_groups_input):
|
| 5 |
# Read the CSV file
|
| 6 |
df = pd.read_csv(file.name, encoding='utf-8')
|
| 7 |
+
|
| 8 |
# Parse fixed groups input
|
| 9 |
fixed_groups = [group.strip() for group in fixed_groups_input.split(';') if group.strip()]
|
| 10 |
fixed_groups_df_list = []
|
|
|
|
| 21 |
|
| 22 |
# Shuffle the remaining DataFrame
|
| 23 |
remaining_df = remaining_df.sample(frac=1).reset_index(drop=True)
|
| 24 |
+
|
| 25 |
# Adjusting fixed groups to include additional members if they're under the specified group size
|
| 26 |
for i, group_df in enumerate(fixed_groups_df_list):
|
| 27 |
while len(group_df) < members_per_group and not remaining_df.empty:
|
|
|
|
| 41 |
names = ', '.join(group['Names'].tolist())
|
| 42 |
grouped_data.append({'Group': group_name, 'Members': names})
|
| 43 |
grouped_df = pd.DataFrame(grouped_data)
|
| 44 |
+
|
| 45 |
return grouped_df
|
| 46 |
|
| 47 |
def main_interface(file, members_per_group, fixed_groups_input):
|
|
|
|
| 62 |
allow_flagging="never"
|
| 63 |
)
|
| 64 |
|
| 65 |
+
iface.launch()
|