Download preprocess.py from Seanyoon/HackHPC: direct link, hf CLI and curl.
- Browser
- Download file 445 Bytes
-
https://huggingface.co/Seanyoon/HackHPC/resolve/main/preprocess.py
- Command line
-
hf download hf://Seanyoon/HackHPC/preprocess.py
-
curl -L -o preprocess.py https://huggingface.co/Seanyoon/HackHPC/resolve/main/preprocess.py
445 Bytes
| import pandas as pd | |
| def preprocess_data(data): | |
| nc = len(data.columns) | |
| nr = len(data.index) | |
| new = [0] * nc | |
| for i in range(nc): | |
| new[i] = len(data.iloc[:, i].unique()) / nr | |
| sorted_index = sorted(range(len(new)), key=lambda k: new[k], reverse=True) | |
| sensitive_cols = list(data.columns[sorted_index[i]] for i in range(nc) if new[sorted_index[i]] > 0.5) | |
| data = data.drop(columns=sensitive_cols) | |
| return data | |