gender-guesser is a Python library that attempts to determine the gender of a person based on their first name. It's a Python port of a Java library and is currently at version 0.4.0. The library returns one of six possible values: 'unknown', 'andy' (androgynous), 'male', 'female', 'mostly_male', or 'mostly_female'. It appears to be actively maintained, with the latest release from late 2016.
pip install gender-guesserVerified import paths — ran on the pinned version, not inferred.
Initialize the Detector and use the `get_gender()` method. Names should ideally be capitalized for accurate results. Optionally, provide a country code (lowercase, with underscores for spaces) for more refined guessing.
Initialize `Detector()` only once in your application and pass the instance around or keep it as a singleton.
When initializing, set `d = Detector(case_sensitive=False)` for case-insensitive matching, or ensure input names are properly capitalized (e.g., `name.capitalize()`).
Understand these return values when interpreting results. If `country` is provided, some names might return `andy` whereas without a country, they might return `female` or `male` (e.g., 'Zoë').
Ensure country names are formatted correctly, typically by converting to lowercase and replacing spaces with underscores (e.g., `country_name.lower().replace(' ', '_')`).Remove any usage of `unknown_value` in `Detector` initialization. Adjust code to handle 'unknown' and 'andy' as distinct return values if upgrading from versions prior to 0.3.0.
Install the package using pip: 'pip install gender-guesser'.
Ensure the 'Gender' class has the 'male' attribute defined, or use the correct attribute name.
Verify that the input name is correctly formatted and exists in the library's database.
pip install gender-guesser
import gender_guesser.detector as gender d = gender.Detector()
No dependency data recorded yet.