jiboia
jiboia is a Python library designed to normalize data and optimize data types of a DataFrame efficiently.
Automated processing and normalization of DataFrames containing inconsistent or heterogeneous data. It automatically identifies data types and formats within each column, standardizes values, and converts columns to the most suitable types, prioritizing data compatibility and memory efficiency. This process reduces memory usage and optimizes data storage and processing, particularly for large datasets.
Do you have an NVIDIA graphics card? Check the version that maximizes GPU utilization and achieve high-speed performance! link: https://pypi.org/project/jiboia-gpu/
Requirements
- Python >= 3.9
By Lucas Muffato 🇧🇷
Key Features
String Normalization
- Trims leading and trailing spaces.
- Removes extra whitespace.
- Detects data inconsistencies (e.g., numeric columns containing strings).
Numeric Conversion**
- Converts numeric strings and floats ending with
.0into integers (int8,int16,int32, …). - Optimizes numeric types for minimal memory usage.
- Recognizes many numeric formats, including:
"0.1","10",".0452","1000.00","0,1",",50","1000.000,00","1,1","10000","5e6","2.5e-2","0e1",".3e-2" - Categories of numeric recognition:
- Standard integers and floats:
"10","0.1","10000","1000.00" - Floats without leading zero:
".0452",".3e-2" - Scientific notation:
"5e6","2.5e-2","0e1" - European-style decimals:
"0,1",",50","1000.000,00" - False floats converted to integers:
"1000.00","0.0","1.0"
- Standard integers and floats:
Date/Time Conversion
- Parses strings representing dates in multiple formats:
yyyy?mm?dd,dd?mm?yyyy,yyyymmdd,dd?mm?yy→datetime. - Converts time strings like
hhmm UTC,hh:mm:ss,hh:mm:ss.s→timedelta.
Null Standardization
- Converts various null representations to
cudf.NA.
Automatic CSV Detection
- Detects the correct delimiter.
- Detects file encoding automatically.
Memory Optimization
- Provides memory usage information for DataFrames.
- Automatically converts columns to the most memory-efficient types.
Test coverage with pytest
- ✅ 100% in Numeric Normalization.
- ✅ 100% in String Normalization.
Table of Contents
Usage
DataFrame Normalization
import pandas as pd
import jiboia as jb
jb.df.normalize(df) # Normalize the entire DataFrame
jb.df.size_info(df) # Show RAM memory usage
Numeric Normalization
jb.num.normalize(df, column_name) # Normalize numeric columns
Date and Time Normalization
jb.dt.normalize(df, column_name) # Convert strings to datetime
jb.time.normalize(df, column_name) # Convert strings to timedelta
Null Normalization
jb.null.normalize(df, column_name) # Convert null values to cudf.NA
String Normalization
jb.str.normalize(df, column_name) # Remove extra spaces and create categories when appropriate
Time Normalization
jb.time.normalize(df, column_name) # Convert time strings to timedelta
Boolean Normalization
jb.bool.normalize(df, column_name) # Convert values to boolean
Automatic CSV Reading
jb.csv.read_files(
folder_path="my_folder/",
start_part=1,
end_part=10
) # Read multiple CSV files automatically
Full Example
Below is a detailed example of creating a DataFrame with messy data and performing full normalization.
import pandas as pd
import jiboia as jb
# ---- Creating a DataFrame with Mixed Dirty Data --- #
# Strings with multiple spaces, at the beginning and end
col_str = "col_str"
col_str_val = [
"Surucuçu",
"Cobra Cipó",
"King Cobra",
"Jararacuçu",
"NA",
" Jiboia",
" Coral Verdadeira ",
"Jararaca ",
"Surucucu",
"NA",
None,
"solid snake",
"null",
"unknown",
"Sea Snake ",
]
# Numbers in string with varied shapes
col_number_str = "col_number_str"
col_number_str_val = [
"1",
"0.1",
"NA",
".1",
"0,1",
",50",
"1000.000,00",
"1,1",
"5e6",
"2.5e-2",
"0e1",
"unknown",
None,
"0e1",
".3e-2",
]
# Integers in string with varied shapes
col_number_false_float_str = "col_number_false_float_str"
col_number_false_float_str_val = [
"10",
".0",
"1000.00",
"0.0",
"100,00",
"1",
None,
"Na",
"10000",
"5e2",
"[1,2,3,4]",
"0e1",
None,
"10",
"1"
]
# Boolean data in string of varying form
col_bool = "col_bool"
col_bool_val = [
'YES',
'No',
None,
'invalid',
'YES',
'No',
None,
'YEs',
'invalido',
'yes',
'NA',
'on',
'off',
None,
'on'
]
# Date data in string and in various formats
col_date = "col_date"
col_date_val = [
'15.06.2018',
'28/01/1990',
None,
'invalid',
'1988 02 08',
'20211212',
'01-02-2024',
'2023/12/20',
'20234550',
'2023-12-12',
'8-2-86',
'8-12-25',
'12-12-12',
'08-12-25',
None
]
# Datetime in string
col_datetime = "col_datetime"
col_datetime_val = [
"2025-01-01 01:10:10",
"2026-02-02 02:20:20",
"2027-03-03 03:30:30",
"2028-04-04 04:40:40",
"2029-05-05 05:50:50",
"2030-06-06 06:00:00",
"2031-07-07 07:10:10",
"invalid",
"2033-09-09 09:30:30",
"2034-10-10 10:40:40",
"2035-11-11 11:50:50",
"2036-12-12 12:00:00",
"2037-01-13 13:10:10",
"2038-02-14 14:20:20",
"2039-03-15 15:30:30",
]
# Time data in string and various forms
col_time = "col_time"
col_time_val = [
"0000UTC",
"0130UTC",
"NA",
"0540 UTC",
"1200UTC",
"00:21",
"1545UTC",
"invalid",
"2359UTC",
"null",
"23",
"20:23",
"10:12:12",
"07:32:12.1247",
None
]
# Strings that can be reduced into categories
col_cat = "col_cat"
col_cat_val = [
"constrictor snake",
"sea snake",
"poisonous snake",
"constrictor snake",
"invalid",
"poisonous snake",
"constrictor snake",
"sea snake",
"poisonous snake",
"constrictor snake",
None,
"poisonous snake",
"constrictor snake",
"sea snake",
"poisonous snake",
]
# Normalizing the dataframe
df: pd.DataFrame = pd.DataFrame({
col_str: col_str_val,
col_number_str: col_number_str_val,
col_number_false_float_str: col_number_false_float_str_val,
col_bool: col_bool_val,
col_date: col_date_val,
col_datetime: col_datetime_val,
col_time: col_time_val,
col_cat: col_cat_val
})
df_normalized = jb.df.normalize(
dataframe=df,
null_values=["invalid"],
to_case='lower',
to_ASCII=True,
match_min_rate=25,
inplace=False,
create_category=True,
show_log=True,
chunk_size=1_000_000
)
# You will see a log like this! #
# Done! all duplicate and edge spaces have been removed
# Done! all strings were converted to lowercase ASCII
# Done! column col_number_str converted to float64
# Done! column col_number_false_float_str converted to Int16
# Done! column col_bool converted to boolean
# Done! column col_date converted to datetime64[s]
# Done! column col_datetime converted to datetime64[ns]
# Done! column col_time converted to timedelta64[ns]
# Done! the column col_cat was converted to a category
# Before types: #
# col_str object
# col_number_str object
# col_number_false_float_str object
# col_bool object
# col_date object
# col_datetime object
# col_time object
# col_cat object
# dtype: object
# After normalizing #
# col_str object
# col_number_str float64
# col_number_false_float_str Int16
# col_bool boolean
# col_date datetime64[s]
# col_datetime datetime64[ns]
# col_time timedelta64[ns]
# col_cat category
# dtype: object
Contribution Guidelines
- Typing is mandatory for all variables, attributes, and functions.
- Automated tests with
pytestare required for all contributions. - Project standards must be followed.
- Imports must be declared in alphabetical order.
Metadata
Release files for jiboia 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jiboia-1.1.0.tar.gz | 27.1 kB | Without provenance | Details for jiboia-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jiboia-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for jiboia-1.1.0-py3-none-any.whl |
Total release size: 57.6 kB
Release files / jiboia-1.1.0.tar.gz
| Download URL | jiboia-1.1.0.tar.gz |
|---|---|
| Size | 27.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
64d7877181cf3254285dc1e5c9e8ac1474e60340dc04c5324eb74d61ac541b15
|
|
BLAKE2b-256 checksum How to use checksums |
9939fc53bb1dd7b36097b8a5aa7cbb60cdcd08825f9c3756dabf003a06acc160
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.11
|
Release files / jiboia-1.1.0-py3-none-any.whl
| Download URL | jiboia-1.1.0-py3-none-any.whl |
|---|---|
| Size | 30.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2b3d6d057162f3ca288418ddc70757fc2b91a2ba44ae0493122b34a29c4a38cd
|
|
BLAKE2b-256 checksum How to use checksums |
25c53523dbd1a75fcb50faac3c5588ea61549426c53f52c8594f9842716ff905
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.11
|
Security for jiboia 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.