Skip to main content

Quickly generate random pandas DataFrames with basic customisation.

Project description

randf

:exclamation: RANDF IS NO LONGER MAINTAINED! Be aware that this software is not tested and won't receive any updates in the future.

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–2026 Manoel Elpidio Pereira de Queiroz Filho.

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.post1.tar.gz (7.9 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.post1-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: randf-0.1.0.post1.tar.gz
  • Upload date:
  • Size: 7.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for randf-0.1.0.post1.tar.gz
Algorithm Hash digest
SHA256 c9aa7203245394810505bd60df895d2e2724d79a9a3ffb74b6452fbe7b1c8949
MD5 0db56d6b2c5262c04a56ca41d7ae15c5
BLAKE2b-256 cce261304d8fafee4acf6efbaaacc8edc7c8e5fa4945f30fc60eb2b23eaf52d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for randf-0.1.0.post1.tar.gz:

Publisher: .gitlab-ci.yml on manoelpqueiroz/randf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: randf-0.1.0.post1-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for randf-0.1.0.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 7f24f4c81b19be563a0f65d35f11abf1b948af06494364cc1a7becfb37597738
MD5 6bd2624892097d35f1bacc8396e2ffdb
BLAKE2b-256 31defcd71a3569caaef40956d9518dc67262834287badebadbd6b6e471211509

See more details on using hashes here.

Provenance

The following attestation bundles were made for randf-0.1.0.post1-py3-none-any.whl:

Publisher: .gitlab-ci.yml on manoelpqueiroz/randf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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