Skip to main content

Tidyverse-like functions for python polars with extended functionalities for science.

Project description

TidyPolars $^{4sci}$

tidypolars4sci provides functions that match as closely as possible to R's Tidyverse functions for manipulating data frames and conducting data analysis in Python using the blazingly fast Polars as backend.

The name tidypolars4sci reflects the module's main features:

  1. Matches the function names and functionalities of R's Tidyverse.
  2. Leverages the performance and efficiency of Polars under the hood.
  3. Tailored for scientific research, extending the default functionalities of both Polars and Tidyverse.

Details

tidypolars4sci is an extended API for Polars. One of the main advantages of using Polars as a data manipulation engine is its exceptional speed when compared to other alternatives (see here).

The primary distinction between tidypolars4sci and Polars lies in user interaction. The frontend functions are designed to closely resemble those available in R's Tidyverse, making it easier for users familiar with that ecosystem to transition to this library.

Another useful feature of tidypolars4sci is its extensive functionality aimed at facilitating data analysis and reporting for scientific research and academic publications. This includes the creation of LaTeX tables, which enhances the presentation of results.

Note: Due to the additional functionalities provided, tidypolars4sci may operate slightly slower than using Polars directly.

Documentation

Available here.

Installation

You can install tidypolars4sci with pip:

$ pip3 install tidypolars4sci

Or through conda:

$ conda install -c conda-forge tidypolars4sci

Basic usage

tidypolars4sci methods are designed to work like tidyverse functions:

import tidypolars4sci as tp

# create tibble data frame
df = tp.tibble(x = range(3),
               y = range(3, 6),
               z = ['a', 'a', 'b'])

(
    df
    .select('x', 'y', 'z')
    .filter(tp.col('x') < 4, tp.col('y') > 1)
    .arrange(tp.desc('z'), 'x')
    .mutate(double_x = tp.col('x') * 2,
            x_plus_y = tp.col('x') + tp.col('y')
            )
)
┌─────┬─────┬─────┬──────────┬──────────┐
 x    y    z    double_x  x_plus_y 
 ---  ---  ---  ---       ---      
 i64  i64  str  i64       i64      
╞═════╪═════╪═════╪══════════╪══════════╡
 2    5    b    4         7        
├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤
 0    3    a    0         3        
├╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌┤
 1    4    a    2         5        
└─────┴─────┴─────┴──────────┴──────────┘

Converting to/from pandas data frames

If you need to use a package that requires pandas or polars data frames, you can convert from a tidypolars4sci tibble to either of those DataFrame formats.

# convert to pandas...
df = df.to_pandas()
# ... or convert to polars
df = df.to_polars()

To convert from a pandas or polars DataFrame to a tidypolars tibble:

# convert from pandas...
df = tp.from_pandas(df)
# or covert from polars
df = tp.from_polars(df)

Similar projects

  • tidypolars: tidypolars was the starting point of tidypolars4sci

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

tidypolars4sci-0.0.1.22.tar.gz (4.4 MB view details)

Uploaded Source

Built Distribution

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

tidypolars4sci-0.0.1.22-py3-none-any.whl (722.0 kB view details)

Uploaded Python 3

File details

Details for the file tidypolars4sci-0.0.1.22.tar.gz.

File metadata

  • Download URL: tidypolars4sci-0.0.1.22.tar.gz
  • Upload date:
  • Size: 4.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for tidypolars4sci-0.0.1.22.tar.gz
Algorithm Hash digest
SHA256 0addf5376cd3af933c1cbfaec3475a89a6b4ce67ef34076012bfb8e0bbf8ba32
MD5 fa3c37c05416e8189902d9d118f5e2af
BLAKE2b-256 b5cdbced915a662d2809e8f819074372741135d140c5833faebd0657e7292b98

See more details on using hashes here.

File details

Details for the file tidypolars4sci-0.0.1.22-py3-none-any.whl.

File metadata

File hashes

Hashes for tidypolars4sci-0.0.1.22-py3-none-any.whl
Algorithm Hash digest
SHA256 0bbeb0d0cd49e9f0996be66f8597436575d42bb3f2e18c6a5ef080b3549a79c3
MD5 2e6443fdee375d47bae99d1b089252df
BLAKE2b-256 bd1d3d35d1a4ee05223db185ed169d53cfb75cfcbb8eea8696d297bbd1371890

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