Skip to main content

Easy Pandas

A declarative Python library built on top of pandas that uses human-readable function names to perform data operations. Inspired by ActiveQuery patterns in PHP, Easy Pandas makes data manipulation more intuitive and expressive.

Installation

pip install ActivePandasQuery

Or install from source:

git clone https://github.com/talamann/ActivePandasQuery.git
cd ActivePandasQuery
pip install -e .

Quick Start

from active_pandas_query import EasyDataFrame
import pandas as pd

# Create an EasyDataFrame from a regular pandas DataFrame
data = {
    'name': ['Alice', 'Bob', 'Charlie', 'David', 'Eve'],
    'age': [25, 30, 35, 28, 32],
    'city': ['New York', 'London', 'Paris', 'Tokyo', 'Berlin'],
    'salary': [50000, 60000, 75000, 55000, 70000]
}
df = EasyDataFrame(data)

# Use human-readable function names!
result = df.filter_age_greaterthan_30()
print(result)

Features

🎯 Declarative Function Names

Write data operations using natural, human-readable function names:

# Filter data
df.filter_age_greaterthan_25()
df.filter_city_equals_london()
df.filter_name_contains_alice()

# Sort data
df.sort_by_age()
df.sort_by_salary_desc()
df.sort_by_age_asc_and_salary_desc()

# Aggregate data
df.aggregate_salary_sum()
df.groupby_city_and_aggregate_salary_mean()

# Select columns
df.select_name_and_age()

# Chain operations
df.filter_age_greaterthan_25().sort_by_salary_desc().select_name_and_salary()

🔗 Method Chaining

Chain multiple operations together for complex queries:

result = (df
    .filter_age_greaterthan_25_and_city_equals_newyork()
    .sort_by_salary_desc()
    .select_name_and_age_and_salary()
)

🔄 Pandas Compatibility

Easy Pandas wraps pandas DataFrames, so you can:

  • Convert back to pandas: df.to_pandas()
  • Access the underlying DataFrame: df.df
  • Use all standard pandas methods and properties

Operation Types

Filtering

Filter data using comparison and string operators:

# Comparison operators
df.filter_age_equals_30()
df.filter_age_greaterthan_25()
df.filter_age_lessthan_40()
df.filter_age_greaterthanorequal_30()
df.filter_salary_between_50000_and_70000()

# String operators
df.filter_name_contains_alice()
df.filter_city_startswith_new()
df.filter_email_endswith_com()

# Null checks
df.filter_age_notna()
df.filter_city_isna()

# Multiple conditions
df.filter_age_greaterthan_25_and_city_equals_london()
df.filter_age_lessthan_30_or_salary_greaterthan_60000()

Supported operators:

  • equals, eq → ==
  • notequals, ne → !=
  • greaterthan, gt → >
  • lessthan, lt → <
  • greaterthanorequal, gte → >=
  • lessthanorequal, lte → <=
  • contains → String contains
  • startswith → String starts with
  • endswith → String ends with
  • isin → Value in list
  • notin → Value not in list
  • between → Value between range
  • isna, isnull → Is null/NA
  • notna, notnull → Not null/NA

Sorting

Sort by one or multiple columns:

# Single column
df.sort_by_age()
df.sort_by_salary_desc()

# Multiple columns
df.sort_by_age_asc_and_salary_desc()
df.sort_by_city_and_name()

Aggregation

Perform aggregations and group operations:

# Simple aggregations
df.aggregate_salary_sum()
df.aggregate_age_mean()
df.aggregate_salary_max()

# Group by operations
df.groupby_city_and_aggregate_salary_mean()
df.groupby_city_and_aggregate_age_count()

Supported aggregation functions:

  • sum → Sum of values
  • mean, avg, average → Mean/average
  • count → Count of values
  • min → Minimum value
  • max → Maximum value
  • std → Standard deviation
  • var → Variance
  • median → Median value
  • nunique → Number of unique values
  • first → First value
  • last → Last value

Column Selection

Select specific columns:

df.select_name_and_age()
df.select_name_and_city_and_salary()

Column Operations

Rename or drop columns:

# Rename columns
df.rename_old_name_to_new_name()

# Drop columns
df.drop_column1_and_column2()

Joining

Join with other DataFrames:

other_df = EasyDataFrame({'city': ['London', 'Paris'], 'country': ['UK', 'France']})

# Join operations
df.join_other_on_city(other=other_df)
df.leftjoin_other_on_city(other=other_df)
df.rightjoin_other_on_city(other=other_df)
df.outerjoin_other_on_city(other=other_df)

Appending

Append DataFrames:

df2 = EasyDataFrame({'name': ['Frank'], 'age': [40]})
df.appendto_other(other=df2)

Advanced Examples

Complex Filtering and Aggregation

# Find high earners in specific cities
result = (df
    .filter_salary_greaterthan_60000_and_city_isin_london_paris()
    .groupby_city_and_aggregate_salary_mean()
)

Multi-step Data Pipeline

# Complete data transformation pipeline
result = (df
    .filter_age_greaterthan_25()
    .filter_salary_notna()
    .sort_by_salary_desc()
    .select_name_and_age_and_salary()
    .reset_index()
)

Working with Strings

# Filter by string patterns
tech_companies = (df
    .filter_company_contains_tech()
    .filter_email_endswith_com()
    .sort_by_name()
)

Comparison with Standard Pandas

Easy Pandas

df.filter_age_greaterthan_30_and_city_equals_london().sort_by_salary_desc()

Standard Pandas

df[(df['age'] > 30) & (df['city'] == 'london')].sort_values('salary', ascending=False)

API Reference

EasyDataFrame

The main class that wraps pandas DataFrame.

Constructor:

EasyDataFrame(data=None, **kwargs)

Methods:

  • to_pandas() → Convert to pandas DataFrame
  • All pandas DataFrame methods are available
  • Dynamic declarative methods based on function names

Properties:

  • df → Access underlying pandas DataFrame
  • columns → DataFrame columns
  • index → DataFrame index
  • shape → DataFrame shape
  • dtypes → Column data types
  • values → DataFrame values

Function Naming Convention

Function names follow this pattern:

<operation>_<column>_<operator>_<value>_<connector>_...

Components:

  • Operation: filter, sort, groupby, aggregate, select, join, etc.
  • Column: Name of the column to operate on
  • Operator: Comparison or string operator
  • Value: The value to compare against
  • Connector: and, or, by, to, on, etc.

Examples:

  • filter_age_greaterthan_30
  • sort_by_name_desc
  • groupby_city_and_aggregate_salary_mean
  • select_name_and_age_and_email

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE file for details.

Roadmap

  • Add more aggregation functions
  • Support for window functions
  • Custom function registration
  • Performance optimizations
  • More comprehensive documentation
  • Additional examples and tutorials

Credits

Inspired by ActiveQuery patterns in PHP frameworks like Yii and Laravel.

Built with ❤️ using pandas.

Metadata

Release files for ActivePandasQuery 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ActivePandasQuery 0.1.0
File Size Uploaded Provenance
activepandasquery-0.1.0.tar.gz 13.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ActivePandasQuery 0.1.0
File Interpreter ABI Platform
activepandasquery-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 28.9 kB

Release files / activepandasquery-0.1.0.tar.gz

Download URL activepandasquery-0.1.0.tar.gz
Size 13.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b36d43b75b246dd6ff48dc9896d130c98c50a1d59b33961036eaf6135f3e0ad0
BLAKE2b-256 checksum
How to use checksums
8aee2f5f2113874565ef58341614bd61a8aba225dfd4ffef39e59310ea8b5e63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / activepandasquery-0.1.0-py3-none-any.whl

Download URL activepandasquery-0.1.0-py3-none-any.whl
Size 15.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a491042916e45a178acc32c00d67971f09174bedf8d2523196291e71dada0224
BLAKE2b-256 checksum
How to use checksums
89ea597cea4bd474e1b94aaeb6d442651bffff9f6bc38f68399ba073b428a655
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Security for ActivePandasQuery 0.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page