Alealejandrooo commited on
Commit
8684f0c
·
verified ·
1 Parent(s): 1d4e574

Delete gradio/process.py

Browse files
Files changed (1) hide show
  1. gradio/process.py +0 -32
gradio/process.py DELETED
@@ -1,32 +0,0 @@
1
- import pandas as pd
2
- import gradio as gr
3
-
4
-
5
- def get_lat_lon(postcodes_df, postcode_mapping):
6
-
7
- try:
8
-
9
- postcode_mapping.rename(columns={'postcode': 'Postal code'}, inplace=True)
10
-
11
- # Normalize postcodes to ensure matching and count occurrences
12
- postcodes_df['Postal code'] = postcodes_df['Postal code'].str.lower().str.replace(' ', '')
13
- postcode_counts = postcodes_df['Postal code'].value_counts().reset_index()
14
- postcode_counts.columns = ['Postal code', 'count']
15
-
16
- # Normalize the postcodes in the mapping DataFrame
17
- postcode_mapping['Postal code'] = postcode_mapping['Postal code'].str.lower().str.replace(' ', '')
18
-
19
- # Merge the counts with the mapping data
20
- result_df = pd.merge(postcode_counts, postcode_mapping, on='Postal code', how='left')
21
-
22
- # Fill NaN values for latitude and longitude where postcode was not found in the mapping
23
- result_df['latitude'] = result_df['latitude'].fillna('')
24
- result_df['longitude'] = result_df['longitude'].fillna('')
25
-
26
- # Optionally, convert the DataFrame to a dictionary if needed, or work directly with the DataFrame
27
- results = result_df.to_dict(orient='records')
28
-
29
- except:
30
- raise gr.Error('Make sure your file contains the postal codes under a column named "Postal code"')
31
-
32
- return results