writer

Polars DataFrame Writer Module

This module provides functionality for writing Polars DataFrames to various file formats. It includes a Writer class and several enums to support different output formats and options.

Classes:

class polars_writer.writer.FormatEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Enumeration of supported file formats for writing Polars DataFrames.

class polars_writer.writer.WriteMethodEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Enumeration of corresponding write methods in Polars for each supported format.

class polars_writer.writer.ReadMethodEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Enumeration of corresponding read methods in Polars for each supported format.

class polars_writer.writer.ScanMethodEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Enumeration of corresponding scan methods in Polars for each supported format.

class polars_writer.writer.ParquetCompressionEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Enumeration of supported compression algorithms for Parquet files.

class polars_writer.writer.DeltaModeEnum(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Enumeration of write modes for Delta Lake operations.

class polars_writer.writer.Writer(format: str, storage_options: Dict[str, Any] = OPT, csv_include_header: bool = OPT, csv_delimiter: str = OPT, csv_line_terminator: str = OPT, csv_quote_char: str = OPT, csv_datetime_format: str = OPT, csv_date_format: str = OPT, csv_float_scientific: bool = OPT, csv_float_precision: int = OPT, csv_null_value: str = OPT, csv_quote_style: str = OPT, parquet_compression: str = OPT, parquet_compression_level: int = OPT, parquet_statistics: bool | str | Dict[str, bool] = OPT, parquet_row_group_size: int | None = OPT, parquet_data_page_size: int | None = OPT, parquet_use_pyarrow: bool = OPT, parquet_pyarrow_options: Dict[str, Any] | None = OPT, parquet_partition_by: str | Sequence[str] | None = OPT, parquet_partition_chunk_size_bytes: int = OPT, delta_mode: str = OPT, delta_overwrite_schema: bool = OPT, delta_write_options: Dict[str, Any] = OPT, delta_merge_options: Dict[str, Any] = OPT)[source]

Writer class for configuring and executing write operations on Polars DataFrames.

This class supports writing DataFrames to various file formats with customizable options.

to_method_and_kwargs() Tuple[str, Dict[str, Any]][source]

Get the appropriate write method and keyword arguments for the chosen format.

Returns:

A tuple containing the write method name and a dictionary of keyword arguments.

to_kwargs() Dict[str, Any][source]

Get the keyword arguments for the write operation.

A dictionary of keyword arguments for the write method.

write(df: DataFrame, file_args: List[Any], write_kwargs: Dict[str, Any] | None = None)[source]

Write the given Polars DataFrame to the specified output.

Parameters:
  • df – The Polars DataFrame to write.

  • file_args – Arguments for the file path or location.

  • write_kwargs – Optional keyword arguments for the write method.

Returns:

The result of the write operation (format-dependent).

to_read_method_and_kwargs() Tuple[str, Dict[str, Any]][source]

Get the appropriate read method and keyword arguments for the chosen format.

Returns:

A tuple containing the read method name and a dictionary of keyword arguments.

to_read_kwargs() Dict[str, Any][source]

Get the appropriate read method and keyword arguments for the chosen format.

Returns:

A tuple containing the read method name and a dictionary of keyword arguments.

read(file_args: List[Any], read_kwargs: Dict[str, Any] | None = None) DataFrame[source]

todo: docstring

to_scan_method_and_kwargs() Tuple[str, Dict[str, Any]][source]

Get the appropriate scan method and keyword arguments for the chosen format.

Returns:

A tuple containing the scan method name and a dictionary of keyword arguments.

to_scan_kwargs() Dict[str, Any][source]

Get the scan arguments for the write operation.

A dictionary of scan arguments for the write method.

scan(file_args: List[Any], scan_kwargs: Dict[str, Any] | None = None) LazyFrame[source]

todo: docstring