Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Download utils/whisp_preprocessing.py from GIZ/chabo_whisp: direct link, hf CLI and curl.
- Browser
- Download file 532 Bytes
-
https://huggingface.co/spaces/GIZ/chabo_whisp/resolve/main/utils/whisp_preprocessing.py
- Command line
-
hf download hf://spaces/GIZ/chabo_whisp/utils/whisp_preprocessing.py
-
curl -L -o whisp_preprocessing.py https://huggingface.co/spaces/GIZ/chabo_whisp/resolve/main/utils/whisp_preprocessing.py
532 Bytes
| import pandas as pd | |
| import openpyxl | |
| def preprocess_whisp_data(response): | |
| # Retrieve response | |
| print(response) | |
| whisp_response = pd.DataFrame(response['properties']) | |
| whisp_response = whisp_response.melt(var_name="Column", value_name="Value") | |
| # Load metadata | |
| whisp_metadata = pd.read_excel('././data/whisp_columns.xlsx') | |
| # Merge datasets | |
| full_df = pd.DataFrame(whisp_response).merge(whisp_metadata, left_on="Column", right_on="Column name").drop(columns={"Column name"}) | |
| return full_df | |