Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -49,6 +49,35 @@ def extract_table_from_markdown(markdown_text, table_start):
|
|
49 |
|
50 |
# return df
|
51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
def markdown_table_to_df(table_content):
|
53 |
"""Convert markdown table to pandas DataFrame."""
|
54 |
# Split the table content into lines
|
@@ -72,7 +101,7 @@ def markdown_table_to_df(table_content):
|
|
72 |
# Convert numeric columns to float and handle Dimension column
|
73 |
for col in df.columns:
|
74 |
if col == "Dimension":
|
75 |
-
df[col] = df[col].apply(lambda x: int(x) if x.isdigit() else
|
76 |
elif col not in ["Model Name", "Publisher", "Open?", "Basemodel", "Matryoshka"]:
|
77 |
df[col] = pd.to_numeric(df[col], errors='coerce')
|
78 |
|
|
|
49 |
|
50 |
# return df
|
51 |
|
52 |
+
# def markdown_table_to_df(table_content):
|
53 |
+
# """Convert markdown table to pandas DataFrame."""
|
54 |
+
# # Split the table content into lines
|
55 |
+
# lines = table_content.split('\n')
|
56 |
+
|
57 |
+
# # Extract headers
|
58 |
+
# headers = [h.strip() for h in lines[0].split('|') if h.strip()]
|
59 |
+
|
60 |
+
# # Extract data
|
61 |
+
# data = []
|
62 |
+
# for line in lines[2:]: # Skip the header separator line
|
63 |
+
# row = [cell.strip() for cell in line.split('|') if cell.strip()]
|
64 |
+
# if row: # Include any non-empty row
|
65 |
+
# # Pad the row with empty strings if it's shorter than the headers
|
66 |
+
# padded_row = row + [''] * (len(headers) - len(row))
|
67 |
+
# data.append(padded_row[:len(headers)]) # Trim if longer than headers
|
68 |
+
|
69 |
+
# # Create DataFrame
|
70 |
+
# df = pd.DataFrame(data, columns=headers)
|
71 |
+
|
72 |
+
# # Convert numeric columns to float and handle Dimension column
|
73 |
+
# for col in df.columns:
|
74 |
+
# if col == "Dimension":
|
75 |
+
# df[col] = df[col].apply(lambda x: int(x) if x.isdigit() else "")
|
76 |
+
# elif col not in ["Model Name", "Publisher", "Open?", "Basemodel", "Matryoshka"]:
|
77 |
+
# df[col] = pd.to_numeric(df[col], errors='coerce')
|
78 |
+
|
79 |
+
# return df
|
80 |
+
|
81 |
def markdown_table_to_df(table_content):
|
82 |
"""Convert markdown table to pandas DataFrame."""
|
83 |
# Split the table content into lines
|
|
|
101 |
# Convert numeric columns to float and handle Dimension column
|
102 |
for col in df.columns:
|
103 |
if col == "Dimension":
|
104 |
+
df[col] = df[col].apply(lambda x: int(x) if x.isdigit() else None)
|
105 |
elif col not in ["Model Name", "Publisher", "Open?", "Basemodel", "Matryoshka"]:
|
106 |
df[col] = pd.to_numeric(df[col], errors='coerce')
|
107 |
|