Skip to main content

A simple package for random DataFrame generation

Project description

randf

Quickly generate random pandas DataFrames with basic customisation.


How to Use

randf provides two functions:

  • randec, which generates a random output of decimal.Decimal objects in a similar manner as numpy.random functions;
  • randf, which generates a random pandas DataFrame given its shape.
>>> from randf import randf
>>> randf(5, 3)
          a         b         c
0  0.719766  0.866084  0.813291
1  0.884956  0.632848  0.423941
2  0.987847  0.977158  0.062507
3  0.457499  0.324980  0.661645
4  0.029068  0.276254  0.638651

randf provides additional parameters to spice up these random DataFrames, such as choosing a different type for the numerical data:

>>> df = randf(5, 2, ntype='decimal')
>>> df
           a          b
0  874.27800  369.91194
1  120.66222  411.98784
2  117.29952  846.79798
>>> df.iloc[0, 0]
Decimal('874.27800')

You can also provide one or more discrete columns randomly populated to go along with the data:

>>> randf(3, 3, dcols=['alpha', 'beta', 'gaga'])
  class         a         b         c
0  gaga  0.242080  0.107986  0.572961
1  beta  0.775823  0.510886  0.932045
2  beta  0.433214  0.504053  0.911336
>>> randf(5, 1, dcols={'team':['corinthians', 'palmares', 'XVzão'],
                       'cup':['paulista', 'brasileiro', 'copa do brasil']})
          team             cup         a
0     palmares  copa do brasil  0.796930
1     palmares        paulista  0.075891
2        XVzão        paulista  0.829730
3     palmares      brasileiro  0.641658
4  corinthians        paulista  0.245822

Changing the order of magnitude of the data is also simple:

>>> randf(5, 6, ntype='int', order=100000)
       a      b      c      d      e      f
0  77844   1653  79738  61744  55072   4577
1  83103  29741  99808  56647  49798  56809
2  61099  35802  95146  71042   8746  36158
3  76772    923  82212  26887  25484  14859
4  90736  85788  17882  46231   2223   1129

And if you want to change the default names of the numerical columns, it is possible to be customised through the names parameter:

>>> randf(6, 3, names=['alpha', 'beta', 'gaga'])
      alpha      beta      gaga
0  0.398819  0.149586  0.661323
1  0.951287  0.029537  0.493456
2  0.287754  0.959519  0.276244
3  0.995609  0.925386  0.309970
4  0.491463  0.252990  0.090506
5  0.748072  0.111197  0.011898

Licence

MIT

Copyright (c) 2021 Manoel Elpidio Pereira de Queiroz Filho.


In case you haven't noticed by now, use of British English is the norm for this project.
RULE BRITANNIA

Project details


Download files

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

Source Distribution

randf-0.1.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

randf-0.1.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file randf-0.1.0.tar.gz.

File metadata

  • Download URL: randf-0.1.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for randf-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d23c1c5271a1eb74aa7156e6519c728cd70c11f90b7998ef35698068150778d2
MD5 033fd5366dfaf698b1ec8ae348863cd3
BLAKE2b-256 ab38a8adacda29fa9027a4056b63c42f15cc352e0097f2a03ceb06b2fddd9a52

See more details on using hashes here.

File details

Details for the file randf-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: randf-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.4

File hashes

Hashes for randf-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 29b17a03c59841e571efaa2558905b5093755a8c4ae1545f4c6b72aa59af6b91
MD5 876c6591b56d9928c7901d9e4eb54021
BLAKE2b-256 b61fd773a766fd522075b90854aeeeba4ffcd460415f982b1ef001a172b2627a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page