Read and write tfs files.
Project description
TFS-Pandas
This package provides reading and writing functionality for Table Format System (TFS) files.
Files are read into a TfsDataFrame
, a class built on top of the famous pandas.DataFrame
, which in addition to the normal behavior attaches an OrderedDict
of headers to the DataFrame
.
See the API documentation for details.
Installing
Installation is easily done via pip
:
python -m pip install tfs-pandas
One can also install in a conda
/mamba
environment via the conda-forge
channel with:
conda install -c conda-forge tfs-pandas
Example Usage
The package is imported as tfs
, and exports top-level functions for reading and writing:
import tfs
# Loading a TFS file is simple
data_frame = tfs.read("path_to_input.tfs", index="index_column")
# You can access and modify the headers with the .headers attribute
useful_variable = data_frame.headers["SOME_KEY"]
data_frame.headers["NEW_KEY"] = some_variable
# Manipulate data as you do with pandas DataFrames
data_frame["NEWCOL"] = data_frame.COL_A * data_frame.COL_B
# You can check the validity of a TfsDataFrame, and choose the behavior in case of errors
tfs.frame.validate(data_frame, non_unique_behavior="raise") # or choose "warn"
# Writing out to disk is simple too
tfs.write("path_to_output.tfs", data_frame, save_index="index_column")
Reading and writing compressed files is also supported, and done automatically based on the provided file extension:
import tfs
# Reading a compressed file is simple, compression format is inferred
df = tfs.read("path_to_input.tfs.gz")
# When writing choose the compression format by providing the appropriate file extension
tfs.write("path_to_output.tfs.bz2", df)
tfs.write("path_to_output.tfs.zip", df)
Package Scope
The package also provides some tools to validate and manipulate TfsDataFrames
and their headers; or lazily manage a collection of TFS files.
For instance with tfs.read_hdf()
and tfs.write_hdf()
the TfsDataFames
can also be saved as hdf5
files, if the hdf5
extra requirements are fulfilled.
The package, however, is made to handle I/O of TFS
files to TfsDataFrames
only: it is not meant to implement various calculations on TfsDataFrames
.
Some calculations are implemented in other packages of the ecosystem.
License
This project is licensed under the MIT License
- see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for tfs_pandas-3.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7b3a223c466ef59c0875b826f313be850cc6ea4287916ece4151357cc61a9f1 |
|
MD5 | 5fe8d58fe040ffab0edbf2158a8799ad |
|
BLAKE2b-256 | e8555ce7143199e071b06d1c3c60a4d9a670796007bf08e10b9ee47e7f7d24bf |