Generate pandas DataFrame quick and easy.
Project description
simple_dataframe_generator
Personal project to generate pandas DataFrame quick and easy.
Installation
pip install simple-dataframe-generator==1.0.3
Supported column types
- Integer -
add_int_col()
- Float -
add_float_col()
- Categorical -
add_cat_col()
- Datetime -
add_datetime_col()
All column types support allow_none
.
Usage
import pandas as pd
import numpy as np
from simple_dataframe_generator import SDG
sdg = SDG()
# add integer column with specified parameters
sdg.add_int_col(col_name='age', min_val=0, max_val=99)
# add integer column with specified parameters, allow missing values
sdg.add_int_col(col_name='favorite_number', min_val=-100, max_val=100, allow_none=True, none_prob=10)
# add float column with specified parameters
sdg.add_float_col('distance', min_val=0.0, max_val=200.0)
# add categorical column with pre-defined categories
categories = ['New York', 'Chicago', 'Los Angeles']
sdg.add_cat_col('city', categories=categories, allow_none=True)
# add datetime column
sdg.add_datetime_col('last_seen', min_date='2020-01-01', max_date='2023-02-01')
# generate pandas DataFrame with specific row count
df = sdg.generate_dataframe(rows=10)
Result
age | favorite_number | distance | city | last_seen | |
---|---|---|---|---|---|
0 | 69 | 81 | 184.517 | Chicago | 2022-08-12 10:39:59 |
1 | 73 | 1 | 118.874 | Chicago | 2021-01-06 11:57:22 |
2 | 10 | 33 | 199.226 | New York | 2020-05-29 10:37:36 |
3 | 47 | -36 | 194.205 | Chicago | 2022-05-30 21:26:24 |
4 | 25 | -66 | 24.9345 | <NA> | 2021-03-26 03:19:09 |
5 | 36 | -12 | 21.0734 | New York | 2021-01-19 03:22:27 |
6 | 21 | <NA> | 165.243 | Chicago | 2022-01-24 04:20:39 |
7 | 37 | <NA> | 3.48131 | Chicago | 2020-05-30 18:37:24 |
8 | 61 | -77 | 90.0552 | New York | 2021-01-07 14:43:35 |
9 | 21 | -19 | 173.3 | Los Angeles | 2020-01-01 00:53:00 |
Author
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file simple_dataframe_generator-1.0.3.tar.gz
.
File metadata
- Download URL: simple_dataframe_generator-1.0.3.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3da8588f07de81d33f3e0b7aa13b89cfc58575a7e3bd13b25072bc96f9a5d1bb |
|
MD5 | c77bb2d80029425e05fb78c9fc12f60b |
|
BLAKE2b-256 | d52cacd804a0cf635742a8f7ac9a13ac81d224593bd2536371517e19ee00ff21 |