Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -42,9 +42,19 @@ def load_data():
|
|
| 42 |
# Ensure department is integer
|
| 43 |
df['birth_department'] = df['birth_department'].astype(int)
|
| 44 |
|
| 45 |
-
# Parse nationalities
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
# Fill NaN values
|
| 50 |
df['diaspora_region'] = df['diaspora_region'].fillna('None')
|
|
|
|
| 42 |
# Ensure department is integer
|
| 43 |
df['birth_department'] = df['birth_department'].astype(int)
|
| 44 |
|
| 45 |
+
# Parse nationalities - handle both string and list formats
|
| 46 |
+
def parse_list_field(x):
|
| 47 |
+
if isinstance(x, list):
|
| 48 |
+
return x
|
| 49 |
+
if isinstance(x, str):
|
| 50 |
+
try:
|
| 51 |
+
return eval(x)
|
| 52 |
+
except:
|
| 53 |
+
return []
|
| 54 |
+
return []
|
| 55 |
+
|
| 56 |
+
df['nationalities'] = df['nationalities'].apply(parse_list_field)
|
| 57 |
+
df['diaspora_countries'] = df['diaspora_countries'].apply(parse_list_field)
|
| 58 |
|
| 59 |
# Fill NaN values
|
| 60 |
df['diaspora_region'] = df['diaspora_region'].fillna('None')
|