Skip to main content

Python wrapper for the R fst package

Project description

py-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 (once published):

pip install py-fst

From GitHub:

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

From a local directory:

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

# Development mode (changes to code reflect immediately without reinstalling)
pip install -e /path/to/py-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.0.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.0-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_r_fst-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 8b3947f10ed323edddddf5d5488c3349cecf01872fe1f5116226cb2df337a3f2
MD5 5222e8b7fbb49c2d1fa079a04038dc67
BLAKE2b-256 aa5f3d9c36c805dec7b7abda308c6f2d64e8624ef7a3666706d4ac935b0eae6e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: py_r_fst-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6d8cc2372d421d39e3304ed2a268454c9a03a66deb245f9702696fbc545f2b52
MD5 d142bc8c67580606dbf4167d36d1c1d3
BLAKE2b-256 495796bb8c069a89e6cb755c03defd20779e37fb9ad6a604bfd356a192b3a021

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