Spaces:
Sleeping
Sleeping
Update appStore/prep_data.py
Browse files- appStore/prep_data.py +8 -0
appStore/prep_data.py
CHANGED
@@ -56,6 +56,14 @@ def process_giz_worldwide():
|
|
56 |
'duration.project.end': 'end_year'
|
57 |
})
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
# Create an empty 'url' column as the new dataset has an empty URL
|
60 |
giz_df['url'] = ''
|
61 |
|
|
|
56 |
'duration.project.end': 'end_year'
|
57 |
})
|
58 |
|
59 |
+
# Convert end_year if it is stored as a numeric epoch (in ms) to "YYYY-MM-DD"
|
60 |
+
def convert_to_date(val):
|
61 |
+
if isinstance(val, (int, float)):
|
62 |
+
return datetime.utcfromtimestamp(val / 1000).strftime("%Y-%m-%d")
|
63 |
+
return val # Already a string
|
64 |
+
|
65 |
+
giz_df['end_year'] = giz_df['end_year'].apply(convert_to_date)
|
66 |
+
|
67 |
# Create an empty 'url' column as the new dataset has an empty URL
|
68 |
giz_df['url'] = ''
|
69 |
|