Skip to main content

Get the gender from first name.

Project description

This package uses the underlying data from the program “gender” by Jorg Michael (described here). Its use is pretty straightforward:

>>> import gender_guesser.detector as gender
>>> d = gender.Detector()
>>> print(d.get_gender(u"Bob"))
>>> print(d.get_gender(u"Sally"))
>>> print(d.get_gender(u"Pauley")) # should be androgynous

The result will be one of unknown (name not found), andy (androgynous), male, female, mostly_male, or mostly_female. The difference between andy and unknown is that the former is found to have the same probability to be male than to be female, while the later means that the name wasn’t found in the database.

I18N is fully supported:

>>> print(d.get_gender(u"\xc1lfr\xfan"))  # u"Álfrún"

Additionally, you can give preference to specific countries:

>>> print(d.get_gender(u"Jamie"))
>>> print(d.get_gender(u"Jamie", u'great_britain'))

Additionally, you can create a detector that is not case sensitive (default is to be case sensitive):

>>> d = gender.Detector(case_sensitive=False)
>>> print(d.get_gender(u"sally"))
>>> print(d.get_gender(u"Sally"))

Try to avoid creating many Detectors, as each creation means reading the data file.


The generator code is distributed under the GPLv3. The data file nam_dict.txt is released under the GNU Free Documentation License.


0.3.0 (2016-07-02)

  • Remove unknown_value init option, since it can be implemented very easily with a wrapper if needed.
  • Return unknown when name is not found and andy when it is valid equally for both male and female.
  • Test README examples as doctests.
  • Fix incorrect country-wise gender detection for non-iso886-15 names coming from line length change after data file conversion to UTF-8. See #gh2. Thanks @miquelcamprodon.

0.2.0 (2015-12-06)

  • Wire in tox to test in both Python 2 and Python 3.
  • Python 2 and 3 compatiblity.
  • Remove obsolete character mapper code.

For previous versions, see sexmachine.


This is a fork of the SexMachine package by Ferhat Elmas. It was created to be able to publish a Python 3 compatible version to PyPI and to be able add some more improvements without bugging the original author.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
gender_guesser-0.4.0-py2.py3-none-any.whl (379.3 kB) Copy SHA256 hash SHA256 Wheel 2.7
gender-guesser-0.4.0.tar.gz (337.2 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page