serde_arrow - convert sequences of structs / maps to and from arrow tables
[Crate info] | [API docs] | Changes | Example | How does it work? | Status | Development | License
Warning: this package is in an experiment at the moment.
Arrow2 is a powerful library to work with data frame like structures.
The surrounding ecosystem includes a rich set of libraries, ranging from data
frames via Polars to query engines via DataFusion.
However, it's API due to the statically typed nature of Rust can be at times
cumbersome to use directly. This package, serde_arrow, tries to bridge this
gap by offering a simple way to convert Rust objects into Arrow objects and vice
versa. serde_arrow relies on the Serde package to
interpret Rust objects. Therefore, adding support for serde_arrow to custom
types is as easy as using Serde's derive macros.
See the implementation notes for details on how it is implemented. This package is optimized for ease of use, not performance.
Example
;
let items = vec!;
// detect the field types and convert the items to arrays
use ;
let fields = serialize_into_fields?;
let arrays = serialize_into_arrays?;
// using the helper method defined in the arrow2 guide at
// https://jorgecarleitao.github.io/arrow2/io/parquet_write.html
use ;
write_chunk?;
The written file can now be read in Python via
# using polars
# using pandas
Development
All common tasks are bundled in the x.py script:
# format the code and run tests
Run python x.py --help for details. The script only uses standard Python
modules can can be run without installing further packages.
License
Copyright (c) 2021 - 2023 Christopher Prohm
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.