Guess which coding scheme or name field contains a collection of values.
def guess_field(codes: Any, min_similarity: float = 80)
Description
Compares the unique supplied values with every field in the built-in countrycode dictionary and ranks fields by their match percentage.
Arguments
codes | Country codes or country names. Scalars and iterable inputs accepted by countrycode are supported. |
min_similarity | Minimum percentage of unique, non-missing values that must occur in a field for that field to be returned. |
Value
A list of dictionaries sorted by decreasing match percentage. Each dictionary contains "code" and "percent_of_unique_matched". Returns an empty list when no non-missing values are supplied or no field meets the threshold.
Examples
guess_field(["DZA", "CAN", "DEU"])[0]