annikwag commited on
Commit
76bd8b0
·
verified ·
1 Parent(s): 83ba479

Update appStore/prep_data.py

Browse files
Files changed (1) hide show
  1. appStore/prep_data.py +10 -3
appStore/prep_data.py CHANGED
@@ -102,9 +102,16 @@ def process_giz_worldwide():
102
  # Convert CRS value to numeric then to integer if possible.
103
  # After reading the JSON file into giz_df, convert the crs_key column:
104
  if 'crs_key' in giz_df.columns:
105
- giz_df['crs_key'] = giz_df['crs_key'].apply(
106
- lambda x: str(int(float(x))).replace('.0', '') if pd.notnull(x) and str(x).strip() != "" else x
107
- )
 
 
 
 
 
 
 
108
 
109
 
110
  # Compute text_size based on merged_text and assign full text to the 'chunks' column
 
102
  # Convert CRS value to numeric then to integer if possible.
103
  # After reading the JSON file into giz_df, convert the crs_key column:
104
  if 'crs_key' in giz_df.columns:
105
+ def clean_crs_key(x):
106
+ if pd.isnull(x):
107
+ return ""
108
+ try:
109
+ # Try converting to float, then to int, then to string.
110
+ return str(int(float(x)))
111
+ except Exception:
112
+ # Fallback: remove trailing ".0" if present.
113
+ return re.sub(r'\.0$', '', str(x))
114
+ giz_df['crs_key'] = giz_df['crs_key'].apply(clean_crs_key)
115
 
116
 
117
  # Compute text_size based on merged_text and assign full text to the 'chunks' column