dumda


Namedumda JSON
Version 4.0.5 PyPI version JSON
download
home_pagehttps://github.com/oliverbdot/dumda
Summarygenerate highly customizable dummy data for data science testing
upload_time2023-01-26 03:12:49
maintainer
docs_urlNone
authorOliver B. Gaither
requires_python>=3.9
licenseMIT
keywords data science python python3
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Dumda 4.0.5

Python Library to get fast extensive Dummy Data for testing https://pypi.org/project/dumda/

## Installation

```
pip install dumda
```

or update from previous version:

```
pip install --update dumda
```

## Usage

This section will cover the functionality of Dumda and how you can power your applicaiton \
with fast customizable randomly generated data.

```python
import dumda
```

### Names

You can generate random names with a handful of specifiers such as the associated \
sex of the name and the format of the name string.

```python
from dumda import random_name, random_names, names_by_prefix

# Basic call with default arguments, returns a full name
n1 = random_name()
print("Hello, world. My name is %s" % n1)

# You can specify the sex of the name generated (1 for female and 0 for male)
# the default is None, so any name of any sex is chosen
male_name = random_name(sex=0)
female_name = random_name(sex=1)
print("Hi, %s. My name is %s" % (male_name, female_name))

# finally you can specify the format of the string
# the default is First Last, but if you mark 'reversed' parameter as True
# it will return the name in Last, First format
formal_name = random_name(reversed=True)
print("Student: %s" % formal_name)

# Most relevantly you can generated n number of names and the parameter list
# stays the same
name_list = random_names(n=7, sex=0, reversed=False)  # returns an iterator
print(list(name_list))

# you can also retrieve names with just a given prefix
BEST_PREFIX = "oliv"
print(names_by_prefix(BEST_PREFIX, n=1, sex=0, full=False))
```

#### Output:

```
Hello, world. My name is Tracie Bradley
Hi, Hugo Flores. My name is Rosario Romero
Student: Benton, Audrea
['Kris Gould', 'Wes Heath', 'Arthur Larsen', 'Lucien Christian', 'Lincoln Moody', 'Cortez Jimenez', 'Giuseppe Meadows']
Oliver
```

### Countries/Cities

You can generate random countries with a handful of specifiers as well.

```python
from dumda import random_country, random_countries, random_city, random_cities, NAMEKEY, POPULATIONKEY, LNGKEY, \
    LATKEY

# Countries
c1 = random_country()  # you can generate a random country like names
print("I'm from %s" % c1)
c2 = random_country(iso=True)  # you can specify whether you want the country string to be in iso3 format
print("COUNTRY: %s" % c2)

# as with names, you can get an iterator of a specified amount of countries
country_codes = random_countries(10, iso=True)
print(list(country_codes))

# Cities
# you can generate random cities. There are 3 optional parameters
# 1. country - there are valid countries to get cities from
#               check COUNTRIES_WITH_CITIES_DATA to see, will raise Exception if not valid
# 2.populous - if marked, it will only return cities that have a population higher than
#               the average population of the dataset
# 3. returnobj - if marked, will return a dictionary object rather than just a city name str
#               - with data related to the city
# 4. pop - define the min population yourself rather than the average
city1 = random_city()
print("Random city: %s" % city1)
norwegian_city = random_city(country="norway")  # country string can be in any casing
print("I wonder how cold it is in %s, Norway" % norwegian_city)
city2 = random_city(country="United States", populous=True)
big_city = random_city(populous=True, pop=1_000_000)
print("%s is a pretty sizable place" % city2)
obj = random_city(country="Colombia", populous=True, returnobj=True)
# Keys are in the __init__ file
lng = obj[LNGKEY]
lat = obj[LATKEY]
print(f"{obj[NAMEKEY]} has a population of {obj[POPULATIONKEY]} and is located at: {lat, lng}")

# and of course, you can get numerous
print(list(random_cities(n=3, country="United States", populous=False, returnobj=True)))

```
#### Output:
```
I'm from Montenegro
COUNTRY: CIV
['ZAF', 'ALB', 'ARG', 'SWZ', 'MOZ', 'GBR', 'SWE', 'BGR', 'CZE', 'POL']
Random city: Presidente Medici
I wonder how cold it is in Haugesund, Norway
Chicago is a pretty sizable place
Pasto has a population of 382236 and is located at: (1.2136, -77.2811)
[{'name': 'Wescosville', 'latitude': 40.5617, 'longitude': -75.5489, 'country': 'United States', 'iso3': 'USA', 'population': 6694}, {'name': 'Moundsville', 'latitude': 39.9221, 'longitude': -80.7422, 'country': 'United States', 'iso3': 'USA', 'population': 8252}, {'name': 'Nampa', 'latitude': 43.5845, 'longitude': -116.5631, 'country': 'United States', 'iso3': 'USA', 'population': 184428}]
```

### Misc.
There is also some other functions for full person recreation, (and then more on that)
```python
from dumda import generate_email, generate_number, Person, names_by_prefix
import json

# generate an email address
email_list = []
names = list(names_by_prefix("oli", n=3, full=True))
for i in range(3):
    # name passed to email generator *must* be a full name of style; First Last
    e = generate_email(names[i])
    email_list.append(e)
    
print(email_list)

# generate a phone number
print("Call me: %s" % generate_number())

# possible parameters
# - area_code (defaults to randomly generated) and country_code (defaults to +1)

DC_AREA_CODE = 202
print("for store hours call: %s" % generate_number(area_code=DC_AREA_CODE))




p = Person() # generate a person object that uses all of the functions in Dumda
print(json.dumps(p.json(), indent=4))
```
#### Output:
```
['ohuffman@baz.net', 'olivesloan@qux.org', 'olivalin@bar.org']
Call me: +1 (743)-792-9493
for store hours call: +1 (202)-293-2130
{
    "name": "Katelynn Brown",
    "location": {
        "name": "Atlantic",
        "latitude": 41.3957,
        "longitude": -95.0138,
        "country": "United States",
        "iso3": "USA",
        "population": 6526
    },
    "email": "katelynnbrown@foo.org",
    "phone": "+1 (793)-759-380"
}
```
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/oliverbdot/dumda",
    "name": "dumda",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "data science,python,python3",
    "author": "Oliver B. Gaither",
    "author_email": "oliverbcontact@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/cb/50/815325b543f9f649c8c770cc03674ab47492636429da7e627520155e24d3/dumda-4.0.5.tar.gz",
    "platform": null,
    "description": "# Dumda 4.0.5\n\nPython Library to get fast extensive Dummy Data for testing https://pypi.org/project/dumda/\n\n## Installation\n\n```\npip install dumda\n```\n\nor update from previous version:\n\n```\npip install --update dumda\n```\n\n## Usage\n\nThis section will cover the functionality of Dumda and how you can power your applicaiton \\\nwith fast customizable randomly generated data.\n\n```python\nimport dumda\n```\n\n### Names\n\nYou can generate random names with a handful of specifiers such as the associated \\\nsex of the name and the format of the name string.\n\n```python\nfrom dumda import random_name, random_names, names_by_prefix\n\n# Basic call with default arguments, returns a full name\nn1 = random_name()\nprint(\"Hello, world. My name is %s\" % n1)\n\n# You can specify the sex of the name generated (1 for female and 0 for male)\n# the default is None, so any name of any sex is chosen\nmale_name = random_name(sex=0)\nfemale_name = random_name(sex=1)\nprint(\"Hi, %s. My name is %s\" % (male_name, female_name))\n\n# finally you can specify the format of the string\n# the default is First Last, but if you mark 'reversed' parameter as True\n# it will return the name in Last, First format\nformal_name = random_name(reversed=True)\nprint(\"Student: %s\" % formal_name)\n\n# Most relevantly you can generated n number of names and the parameter list\n# stays the same\nname_list = random_names(n=7, sex=0, reversed=False)  # returns an iterator\nprint(list(name_list))\n\n# you can also retrieve names with just a given prefix\nBEST_PREFIX = \"oliv\"\nprint(names_by_prefix(BEST_PREFIX, n=1, sex=0, full=False))\n```\n\n#### Output:\n\n```\nHello, world. My name is Tracie Bradley\nHi, Hugo Flores. My name is Rosario Romero\nStudent: Benton, Audrea\n['Kris Gould', 'Wes Heath', 'Arthur Larsen', 'Lucien Christian', 'Lincoln Moody', 'Cortez Jimenez', 'Giuseppe Meadows']\nOliver\n```\n\n### Countries/Cities\n\nYou can generate random countries with a handful of specifiers as well.\n\n```python\nfrom dumda import random_country, random_countries, random_city, random_cities, NAMEKEY, POPULATIONKEY, LNGKEY, \\\n    LATKEY\n\n# Countries\nc1 = random_country()  # you can generate a random country like names\nprint(\"I'm from %s\" % c1)\nc2 = random_country(iso=True)  # you can specify whether you want the country string to be in iso3 format\nprint(\"COUNTRY: %s\" % c2)\n\n# as with names, you can get an iterator of a specified amount of countries\ncountry_codes = random_countries(10, iso=True)\nprint(list(country_codes))\n\n# Cities\n# you can generate random cities. There are 3 optional parameters\n# 1. country - there are valid countries to get cities from\n#               check COUNTRIES_WITH_CITIES_DATA to see, will raise Exception if not valid\n# 2.populous - if marked, it will only return cities that have a population higher than\n#               the average population of the dataset\n# 3. returnobj - if marked, will return a dictionary object rather than just a city name str\n#               - with data related to the city\n# 4. pop - define the min population yourself rather than the average\ncity1 = random_city()\nprint(\"Random city: %s\" % city1)\nnorwegian_city = random_city(country=\"norway\")  # country string can be in any casing\nprint(\"I wonder how cold it is in %s, Norway\" % norwegian_city)\ncity2 = random_city(country=\"United States\", populous=True)\nbig_city = random_city(populous=True, pop=1_000_000)\nprint(\"%s is a pretty sizable place\" % city2)\nobj = random_city(country=\"Colombia\", populous=True, returnobj=True)\n# Keys are in the __init__ file\nlng = obj[LNGKEY]\nlat = obj[LATKEY]\nprint(f\"{obj[NAMEKEY]} has a population of {obj[POPULATIONKEY]} and is located at: {lat, lng}\")\n\n# and of course, you can get numerous\nprint(list(random_cities(n=3, country=\"United States\", populous=False, returnobj=True)))\n\n```\n#### Output:\n```\nI'm from Montenegro\nCOUNTRY: CIV\n['ZAF', 'ALB', 'ARG', 'SWZ', 'MOZ', 'GBR', 'SWE', 'BGR', 'CZE', 'POL']\nRandom city: Presidente Medici\nI wonder how cold it is in Haugesund, Norway\nChicago is a pretty sizable place\nPasto has a population of 382236 and is located at: (1.2136, -77.2811)\n[{'name': 'Wescosville', 'latitude': 40.5617, 'longitude': -75.5489, 'country': 'United States', 'iso3': 'USA', 'population': 6694}, {'name': 'Moundsville', 'latitude': 39.9221, 'longitude': -80.7422, 'country': 'United States', 'iso3': 'USA', 'population': 8252}, {'name': 'Nampa', 'latitude': 43.5845, 'longitude': -116.5631, 'country': 'United States', 'iso3': 'USA', 'population': 184428}]\n```\n\n### Misc.\nThere is also some other functions for full person recreation, (and then more on that)\n```python\nfrom dumda import generate_email, generate_number, Person, names_by_prefix\nimport json\n\n# generate an email address\nemail_list = []\nnames = list(names_by_prefix(\"oli\", n=3, full=True))\nfor i in range(3):\n    # name passed to email generator *must* be a full name of style; First Last\n    e = generate_email(names[i])\n    email_list.append(e)\n    \nprint(email_list)\n\n# generate a phone number\nprint(\"Call me: %s\" % generate_number())\n\n# possible parameters\n# - area_code (defaults to randomly generated) and country_code (defaults to +1)\n\nDC_AREA_CODE = 202\nprint(\"for store hours call: %s\" % generate_number(area_code=DC_AREA_CODE))\n\n\n\n\np = Person() # generate a person object that uses all of the functions in Dumda\nprint(json.dumps(p.json(), indent=4))\n```\n#### Output:\n```\n['ohuffman@baz.net', 'olivesloan@qux.org', 'olivalin@bar.org']\nCall me: +1 (743)-792-9493\nfor store hours call: +1 (202)-293-2130\n{\n    \"name\": \"Katelynn Brown\",\n    \"location\": {\n        \"name\": \"Atlantic\",\n        \"latitude\": 41.3957,\n        \"longitude\": -95.0138,\n        \"country\": \"United States\",\n        \"iso3\": \"USA\",\n        \"population\": 6526\n    },\n    \"email\": \"katelynnbrown@foo.org\",\n    \"phone\": \"+1 (793)-759-380\"\n}\n```",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "generate highly customizable dummy data for data science testing",
    "version": "4.0.5",
    "split_keywords": [
        "data science",
        "python",
        "python3"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cb50815325b543f9f649c8c770cc03674ab47492636429da7e627520155e24d3",
                "md5": "3ed17849c16968e1b228f788faab6744",
                "sha256": "5db26b9d8aefc4c2b076e01fd69ea96e247a5def43e69703c4acbd7eafe750ef"
            },
            "downloads": -1,
            "filename": "dumda-4.0.5.tar.gz",
            "has_sig": false,
            "md5_digest": "3ed17849c16968e1b228f788faab6744",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 2476473,
            "upload_time": "2023-01-26T03:12:49",
            "upload_time_iso_8601": "2023-01-26T03:12:49.443690Z",
            "url": "https://files.pythonhosted.org/packages/cb/50/815325b543f9f649c8c770cc03674ab47492636429da7e627520155e24d3/dumda-4.0.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-26 03:12:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "oliverbdot",
    "github_project": "dumda",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "dumda"
}
        
Elapsed time: 0.03558s