Skip to main content

Perse is a unified DataFrame package that combines the best of Pandas, Polars, and DuckDB for efficient data handling, querying, and visualization.

Project description

Python PackagePyPISupported Python Versions

Perse

Perse is an experimental Python package that combines some of the most widely-used functionalities from the powerhouse libraries Pandas, Polars, and DuckDB into a single, unified DataFrame object. The goal of Perse is to provide a streamlined and efficient interface, leveraging the strengths of these libraries to create a versatile data handling experience.

This package is currently experimental, with a focus on essential functions. We plan to expand its capabilities by integrating more features from Pandas, Polars, and DuckDB in future versions.

Key Features

The Perse DataFrame currently supports the following functionalities:

1. Data Manipulation

Core data-handling tools inspired by Pandas and Polars.

  • Indexing and Selection: Access specific rows or columns with .loc and .iloc properties.
  • Column Operations: Add, modify, or delete columns efficiently.
  • Row Filtering: Filter rows based on specific conditions.
  • Aggregation: Summarize data with aggregations like sum, mean, count.
  • Sorting: Sort data based on column values.
  • Custom Function Application: Apply custom functions to columns, supporting both element-wise operations and complex transformations.

2. SQL Querying

Use DuckDB's SQL engine to run SQL queries directly on the DataFrame, ideal for complex filtering and data manipulation.

  • Direct SQL Queries: Run SQL queries directly on data using DuckDB’s powerful engine.
  • Seamless Integration: Convert between Polars and DuckDB seamlessly for efficient querying on large datasets.
  • Advanced Filtering: Filter, join, and group data using SQL syntax.

3. Data Transformation

A collection of versatile data transformation functions.

  • Pivot and Unpivot: Reshape data for summary reports and visualizations.
  • Melt/Stack: Transform data between wide and long formats.
  • Mapping and Replacing: Map values based on conditions or replace them in columns.
  • Grouping and Window Functions: Group by specific columns and apply aggregations or window functions for advanced data summarization.

4. Compatibility and Conversion

Interoperability between Pandas, Polars, and DuckDB formats, offering flexibility in data manipulation.

  • Pandas Compatibility: Conversion utilities to easily move data between Pandas and Polars.
  • Automatic Data Handling: Automatically convert and handle data depending on the operation, allowing users to work flexibly with either Pandas or Polars.
  • File I/O Support: Read and write from common file formats (e.g., CSV, Parquet, JSON).

5. Visualization

Basic plotting capabilities that make it easy to visualize data directly from the Perse DataFrame.

  • Line, Bar, and Scatter Plots: Quick visualizations with common plot types.
  • Customization: Customize plot titles, labels, and legends with Matplotlib.
  • Direct Plotting: Plot directly from the Perse DataFrame, which internally uses Pandas’ Matplotlib integration.

6. Data Integrity and Locking

Features designed to prevent accidental modifications and ensure data integrity.

  • Locking Mechanism: Lock the DataFrame to prevent accidental edits.
  • Unlocking: Explicitly unlock to allow modifications.
  • Validation: Ensure data type consistency across columns for critical operations.

Installation

To install Perse, run:

pip install perse

Usage

from perse import DataFrame
import numpy as np

# Sample data
data = {"A": np.random.randint(0, 100, 10), "B": np.random.random(10), "C": np.random.choice(["X", "Y", "Z"], 10)}
df = DataFrame(data)

# 1. Add a New Column 
df.add_column("D", np.random.random(10), inplace=True)
print("DataFrame with new column D:\n", df)

# 2. Filter Rows
df2 = df.filter_rows(df.dl["A"] > 50, inplace=False) # default inplace = False 
print("Filtered DataFrame (A > 50):\n", df2)

# 3. SQL Querying with DuckDB
result = df.query("SELECT A, AVG(B) AS avg_B FROM this GROUP BY A")
print("SQL Query Result:\n", result.df)

# 4. Visualization
df.plot(kind="scatter", x="A", y="B", title="Scatter Plot of A vs B", xlabel="A values", ylabel="B values")

# 5. Convert to Pandas
pandas_df = df.to_pandas()
print("Converted to Pandas DataFrame:\n", pandas_df)

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

perse-0.1.7.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

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

perse-0.1.7-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file perse-0.1.7.tar.gz.

File metadata

  • Download URL: perse-0.1.7.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.4.30

File hashes

Hashes for perse-0.1.7.tar.gz
Algorithm Hash digest
SHA256 9cd865a108f5e407ab567e0a3a99bd7e6801daebda58875614eb9d73caf690c4
MD5 7aa13efb54a31c602273ac847c767346
BLAKE2b-256 e58946650adc45a6929a4125f00693df5fcad652eb88b32d0658e10f25aa04a8

See more details on using hashes here.

File details

Details for the file perse-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: perse-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.4.30

File hashes

Hashes for perse-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 b3528b0dc6dc1621b13f84c13a001669ed46f36eb62c45a673281bf8a60d1905
MD5 4941feee2aab2cf7372e9db0ae40b8a8
BLAKE2b-256 585fee9a5be14cc5680a7e5c631241ddeb3b5c29ac71715bf1eb47700bacc522

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