Skip to main content

Helper functions for pandas data analysis, inspired by R

Project description

baribal 🐻

Build Status PyPI version PyPI downloads Coverage License Python Versions Code style: ruff

A Python package extending pandas and polars with helper functions for simpler exploratory data analysis and data wrangling, inspired by R's tidyverse packages.

Why Baribal?

While pandas and polars are incredibly powerful, some R functions like glimpse(), tabyl(), or clean_names() make data exploration and manipulation particularly smooth. Baribal brings these functionalities to Python, helping you to:

  • Get quick, insightful overviews of your DataFrames
  • Perform common data cleaning tasks with less code
  • Handle missing values more intuitively
  • Generate summary statistics with minimal effort

Features

Core Functions

🔍 glimpse()

R-style enhanced DataFrame preview that works with both pandas and polars:

import pandas as pd
import baribal as bb

df = pd.DataFrame({
    'id': range(1, 6),
    'name': ['John Doe', 'Jane Smith', 'Bob Wilson', 'Alice Brown', 'Charlie Davis'],
    'age': [25, 30, 35, 28, 42],
    'score': [92.5, 88.0, None, 95.5, 90.0]
})

bb.glimpse(df)

Output:

Observations: 5
Variables: 4
DataFrame type: pandas
$ id    <int> 1, 2, 3, 4, 5
$ name  <chr> "John Doe", "Jane Smith", "Bob Wilson", "Alice Brown", "Charlie Davis"
$ age   <int> 25, 30, 35, 28, 42
$ score <num> 92.5, 88.0, NA, 95.5, 90.0

📊 tabyl()

Enhanced cross-tabulations with integrated statistics:

import baribal as bb

# Single variable frequency table
result, _ = bb.tabyl(df, 'category')

# Two-way cross-tabulation with chi-square statistics
result, stats = bb.tabyl(df, 'category', 'status')

Data Cleaning

🧹 clean_names()

Smart column name cleaning with multiple case styles:

import baribal as bb

df = pd.DataFrame({
    "First Name": [],
    "Last.Name": [],
    "Email@Address": [],
    "Phone #": []
})

# Snake case (default)
bb.clean_names(df)
# → columns become: ['first_name', 'last_name', 'email_address', 'phone']

# Camel case
bb.clean_names(df, case='camel')
# → columns become: ['firstName', 'lastName', 'emailAddress', 'phone']

# Pascal case
bb.clean_names(df, case='pascal')
# → columns become: ['FirstName', 'LastName', 'EmailAddress', 'Phone']

🔄 rename_all()

Batch rename columns using patterns:

import baribal as bb

# Using regex pattern
bb.rename_all(df, r'Col_(\d+)')  # Extracts numbers from column names

# Using case transformation
bb.rename_all(df, lambda x: x.lower())  # Convert all to lowercase

Analysis Tools

🔍 missing_summary()

Comprehensive missing values analysis:

import baribal as bb

summary = bb.missing_summary(df)
# Returns DataFrame with missing value statistics for each column

Installation

pip install baribal

Dependencies

  • Python >= 3.8
  • pandas >= 1.0.0
  • polars >= 0.20.0 (optional)
  • numpy
  • scipy

Development

This project uses modern Python development tools:

  • uv for fast, reliable package management
  • ruff for lightning-fast linting and formatting
  • pytest for testing

To set up the development environment:

make install

To run tests:

make test

Contributing

Contributions are welcome! Whether it's:

  • Suggesting new R-inspired features
  • Improving documentation
  • Adding test cases
  • Reporting bugs

Please check out our Contributing Guidelines for details on our git commit conventions and development process.

License

MIT License

Acknowledgments

Inspired by various R packages including:

  • dplyr
  • janitor
  • tibble
  • naniar

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

baribal-0.1.0.tar.gz (18.5 kB view details)

Uploaded Source

Built Distribution

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

baribal-0.1.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: baribal-0.1.0.tar.gz
  • Upload date:
  • Size: 18.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for baribal-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a5559ff1adc6befd81ce705b03aa2ab5c787ad86e1947b105756edec684d8996
MD5 387078ddb8b39fce0400779564106b73
BLAKE2b-256 27bb2e65b4085c058c3bf772513e286897dd806fa750a0c45b8141b66c0cd75b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: baribal-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for baribal-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 020779d6e8c08d1d568f9e6d2b21af53d8a80f3a514db78adef11ee4fc6bda48
MD5 ce9a2a78a0c064977e9bb20dcc263bc5
BLAKE2b-256 26b4e96539b2e38d925373432ab6e046071d013e9f5758230058bfc080d047de

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