Skip to main content

Python wrapper for the R fst package

Project description

py-r-fst

Python wrapper for the R fst package. The fst package provides a fast, easy and flexible way to serialize data frames.

Installation

From PyPI:

pip install py-r-fst

From GitHub:

pip install git+https://github.com/msdavid/py-r-fst.git

From a local directory:

# Standard installation
pip install /path/to/py-r-fst

# Development mode (changes to code reflect immediately without reinstalling)
pip install -e /path/to/py-r-fst

Requirements

  • Python 3.6+
  • R with the 'fst' package installed
  • rpy2
  • pandas

You need to have R installed and the fst package:

install.packages("fst")

Usage

import pandas as pd
from pyfst import read_fst, write_fst

# Create a sample DataFrame
df = pd.DataFrame({
    'a': [1, 2, 3],
    'b': ['x', 'y', 'z']
})

# Write to fst file
write_fst(df, 'data.fst', compress=50)

# Read from fst file
df_read = read_fst('data.fst')
print(df_read)

# Read only specific columns
df_partial = read_fst('data.fst', columns=['a'])
print(df_partial)

# Read a subset of rows
df_rows = read_fst('data.fst', from_=0, to=1)
print(df_rows)

API

read_fst(path, columns=None, from_=None, to=None, as_data_table=False)

Read a fst file into a pandas DataFrame.

Parameters:

  • path: Path to the fst file.
  • columns: List of column names to read. If None, all columns are read.
  • from_: First row to read (0-based indexing). If None, start from the first row.
  • to: Last row to read (0-based indexing). If None, read to the end.
  • as_data_table: If True, return a data.table object. Otherwise, return a pandas DataFrame.

Returns:

  • pandas.DataFrame or data.table: Data from the fst file.

write_fst(df, path, compress=50)

Write a pandas DataFrame to a fst file.

Parameters:

  • df: pandas.DataFrame, data to write.
  • path: Path where to save the fst file.
  • compress: Compression level (0-100). Higher means more compression but slower.

Returns:

  • None

License

Apache 2.0

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

py_r_fst-0.1.1.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

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

py_r_fst-0.1.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file py_r_fst-0.1.1.tar.gz.

File metadata

  • Download URL: py_r_fst-0.1.1.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.3

File hashes

Hashes for py_r_fst-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3a02b3244e6d1240c20f54fb43aff6a259fe65299a1b24d6aa9735ae3758c0ea
MD5 dbf349ffb58ccd2f3acff68c014d39a6
BLAKE2b-256 a380867479878a0ad9319fee3870d42dd13a9646e329d0c7c1dc2c4606f609e1

See more details on using hashes here.

File details

Details for the file py_r_fst-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: py_r_fst-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.3

File hashes

Hashes for py_r_fst-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 191306bb362d4b35bb817b4f8676921ff0c6ce00113341bdffa4fe216caccdd1
MD5 7e35376aa2fba5f8de48ef658e584745
BLAKE2b-256 9569e199e8dcd45daf4b1103ae5a982b18ddf1dd581af5db2c665227aca67997

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