Name | tfs-pandas JSON |
Version |
3.9.0
JSON |
| download |
home_page | None |
Summary | Read and write tfs files. |
upload_time | 2024-11-14 16:13:22 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | MIT |
keywords |
mad-x
tfs
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# TFS-Pandas
[![Cron Testing](https://github.com/pylhc/tfs/workflows/Cron%20Testing/badge.svg)](https://github.com/pylhc/tfs/actions?query=workflow%3A%22Cron+Testing%22)
[![Code Climate coverage](https://img.shields.io/codeclimate/coverage/pylhc/tfs.svg?style=popout)](https://codeclimate.com/github/pylhc/tfs)
[![Code Climate maintainability (percentage)](https://img.shields.io/codeclimate/maintainability-percentage/pylhc/tfs.svg?style=popout)](https://codeclimate.com/github/pylhc/tfs)
<!-- [![GitHub last commit](https://img.shields.io/github/last-commit/pylhc/tfs.svg?style=popout)](https://github.com/pylhc/tfs/) -->
[![GitHub release](https://img.shields.io/github/v/release/pylhc/tfs?logo=github)](https://github.com/pylhc/tfs/)
[![PyPI Version](https://img.shields.io/pypi/v/tfs-pandas?label=PyPI&logo=pypi)](https://pypi.org/project/tfs-pandas/)
[![Conda-forge Version](https://img.shields.io/conda/vn/conda-forge/tfs-pandas?color=orange&logo=anaconda)](https://anaconda.org/conda-forge/tfs-pandas)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5070986.svg)](https://doi.org/10.5281/zenodo.5070986)
This package provides reading and writing functionality for [**Table Format System (TFS)** files](http://mad.web.cern.ch/mad/madx.old/Introduction/tfs.html).
Files are read into a `TfsDataFrame`, a class built on top of the famous `pandas.DataFrame`, which in addition to the normal behavior attaches a dictionary of headers to the `DataFrame`.
See the [API documentation](https://pylhc.github.io/tfs/) for details.
## Installing
Installation is easily done via `pip`:
```bash
python -m pip install tfs-pandas
```
One can also install in a `conda`/`mamba` environment via the `conda-forge` channel with:
```bash
conda install -c conda-forge tfs-pandas
```
## Example Usage
The package is imported as `tfs`, and exports top-level functions for reading and writing:
```python
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:
```python
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)
```
## License
This project is licensed under the `MIT License` - see the [LICENSE](LICENSE) file for details.
Raw data
{
"_id": null,
"home_page": null,
"name": "tfs-pandas",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "MAD-X, TFS",
"author": null,
"author_email": "OMC Team <pylhc@github.com>",
"download_url": "https://files.pythonhosted.org/packages/49/b0/6062ab9cc0f5ce9ccbbf055a20cb3853975f7a60a97d07f4b885992f8aad/tfs_pandas-3.9.0.tar.gz",
"platform": null,
"description": "# TFS-Pandas\n\n[![Cron Testing](https://github.com/pylhc/tfs/workflows/Cron%20Testing/badge.svg)](https://github.com/pylhc/tfs/actions?query=workflow%3A%22Cron+Testing%22)\n[![Code Climate coverage](https://img.shields.io/codeclimate/coverage/pylhc/tfs.svg?style=popout)](https://codeclimate.com/github/pylhc/tfs)\n[![Code Climate maintainability (percentage)](https://img.shields.io/codeclimate/maintainability-percentage/pylhc/tfs.svg?style=popout)](https://codeclimate.com/github/pylhc/tfs)\n<!-- [![GitHub last commit](https://img.shields.io/github/last-commit/pylhc/tfs.svg?style=popout)](https://github.com/pylhc/tfs/) -->\n[![GitHub release](https://img.shields.io/github/v/release/pylhc/tfs?logo=github)](https://github.com/pylhc/tfs/)\n[![PyPI Version](https://img.shields.io/pypi/v/tfs-pandas?label=PyPI&logo=pypi)](https://pypi.org/project/tfs-pandas/)\n[![Conda-forge Version](https://img.shields.io/conda/vn/conda-forge/tfs-pandas?color=orange&logo=anaconda)](https://anaconda.org/conda-forge/tfs-pandas)\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.5070986.svg)](https://doi.org/10.5281/zenodo.5070986)\n\nThis package provides reading and writing functionality for [**Table Format System (TFS)** files](http://mad.web.cern.ch/mad/madx.old/Introduction/tfs.html).\nFiles are read into a `TfsDataFrame`, a class built on top of the famous `pandas.DataFrame`, which in addition to the normal behavior attaches a dictionary of headers to the `DataFrame`.\n\nSee the [API documentation](https://pylhc.github.io/tfs/) for details.\n\n## Installing\n\nInstallation is easily done via `pip`:\n\n```bash\npython -m pip install tfs-pandas\n```\n\nOne can also install in a `conda`/`mamba` environment via the `conda-forge` channel with:\n\n```bash\nconda install -c conda-forge tfs-pandas\n```\n\n## Example Usage\n\nThe package is imported as `tfs`, and exports top-level functions for reading and writing:\n\n```python\nimport tfs\n\n# Loading a TFS file is simple\ndata_frame = tfs.read(\"path_to_input.tfs\", index=\"index_column\")\n\n# You can access and modify the headers with the .headers attribute\nuseful_variable = data_frame.headers[\"SOME_KEY\"]\ndata_frame.headers[\"NEW_KEY\"] = some_variable\n\n# Manipulate data as you do with pandas DataFrames\ndata_frame[\"NEWCOL\"] = data_frame.COL_A * data_frame.COL_B\n\n# You can check the validity of a TfsDataFrame, and choose the behavior in case of errors\ntfs.frame.validate(data_frame, non_unique_behavior=\"raise\") # or choose \"warn\"\n\n# Writing out to disk is simple too\ntfs.write(\"path_to_output.tfs\", data_frame, save_index=\"index_column\")\n```\n\nReading and writing compressed files is also supported, and done automatically based on the provided file extension:\n\n```python\nimport tfs\n\n# Reading a compressed file is simple, compression format is inferred\ndf = tfs.read(\"path_to_input.tfs.gz\")\n\n# When writing choose the compression format by providing the appropriate file extension\ntfs.write(\"path_to_output.tfs.bz2\", df)\ntfs.write(\"path_to_output.tfs.zip\", df)\n```\n\n## License\n\nThis project is licensed under the `MIT License` - see the [LICENSE](LICENSE) file for details.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Read and write tfs files.",
"version": "3.9.0",
"project_urls": {
"changelog": "https://github.com/pylhc/tfs/blob/master/CHANGELOG.md",
"documentation": "https://pylhc.github.io/tfs/",
"homepage": "https://github.com/pylhc/tfs",
"repository": "https://github.com/pylhc/tfs"
},
"split_keywords": [
"mad-x",
" tfs"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7475f8ace8e2447998dd2ec735fe503c7ce760535623f29cd1a62d2ca55be166",
"md5": "f208a84b9cb2a6f15601c924c42a2d46",
"sha256": "15198af21e5594a4b64506a9cddf61363d438bc527a456ff49b031e3a89027e4"
},
"downloads": -1,
"filename": "tfs_pandas-3.9.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f208a84b9cb2a6f15601c924c42a2d46",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 25765,
"upload_time": "2024-11-14T16:13:21",
"upload_time_iso_8601": "2024-11-14T16:13:21.668125Z",
"url": "https://files.pythonhosted.org/packages/74/75/f8ace8e2447998dd2ec735fe503c7ce760535623f29cd1a62d2ca55be166/tfs_pandas-3.9.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "49b06062ab9cc0f5ce9ccbbf055a20cb3853975f7a60a97d07f4b885992f8aad",
"md5": "d12589e05399f79c66e968b8a6bf78ad",
"sha256": "06204a9629f3007148b46d4d0922c028644b6e3d8063fb16cb3db7cc1e9d7630"
},
"downloads": -1,
"filename": "tfs_pandas-3.9.0.tar.gz",
"has_sig": false,
"md5_digest": "d12589e05399f79c66e968b8a6bf78ad",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 26934,
"upload_time": "2024-11-14T16:13:22",
"upload_time_iso_8601": "2024-11-14T16:13:22.716768Z",
"url": "https://files.pythonhosted.org/packages/49/b0/6062ab9cc0f5ce9ccbbf055a20cb3853975f7a60a97d07f4b885992f8aad/tfs_pandas-3.9.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-14 16:13:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "pylhc",
"github_project": "tfs",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "tfs-pandas"
}