| [ Web Proxy ] |
| Viewing: https://arrow.apache.org/docs/python/api/../generated/pyarrow.dataset.FilenamePartitioning.html | [Back] [Original] |
Section Navigation
Bases: KeyValuePartitioning
A Partitioning based on a specified Schema.
The FilenamePartitioning expects one segment in the file name for each
field in the schema (all fields are required to be present) separated
by _. For example given schema<year:int16, month:int8> the name
"2009_11_" would be parsed to (year == 2009 and month == 11).
SchemaThe schema that describes the partitions present in the file path.
dict[str, Array]If the type of any field of schema is a dictionary type, the corresponding entry of dictionaries must be an array containing every value which may be taken by the corresponding column or an error will be raised in parsing.
str, default uriAfter splitting paths into segments, decode the segments. Valid values are uri (URI-decode segments) and none (leave as-is).
Examples
>>> from pyarrow.dataset import FilenamePartitioning
>>> partitioning = FilenamePartitioning(
... pa.schema([("year", pa.int16()), ("month", pa.int8())]))
>>> print(partitioning.parse("2009_11_data.parquet"))
((year == 2009) and (month == 11))
Methods
|
|
|
Discover a FilenamePartitioning. |
|
Convert a filter expression into a tuple of (directory, filename) using the current partitioning scheme |
|
Parse a path into a partition expression. |
Attributes
The unique values for each partition field, if available. |
|
The arrow Schema attached to the partitioning. |
The unique values for each partition field, if available.
Those values are only available if the Partitioning object was created through dataset discovery from a PartitioningFactory, or if the dictionaries were manually specified in the constructor. If no dictionary field is available, this returns an empty list.
Discover a FilenamePartitioning.
list of strThe names to associate with the values from the subdirectory names. If schema is given, will be populated from the schema.
FalseWhen inferring a schema for partition fields, yield dictionary encoded types instead of plain types. This can be more efficient when materializing virtual columns, and Expressions parsed by the finished Partitioning will include dictionaries of all unique inspected values for each field.
Schema, default NoneUse this schema instead of inferring a schema from partition values. Partition values will be validated against this schema before accumulation into the Partitionings dictionary.
str, default uriAfter splitting paths into segments, decode the segments. Valid values are uri (URI-decode segments) and none (leave as-is).
PartitioningFactoryTo be used in the FileSystemFactoryOptions.
Convert a filter expression into a tuple of (directory, filename) using the current partitioning scheme
Examples
Specify the Schema for paths like /2009/June:
>>> import pyarrow as pa
>>> import pyarrow.dataset as ds
>>> import pyarrow.compute as pc
>>> part = ds.partitioning(pa.schema([("year", pa.int16()),
... ("month", pa.string())]))
>>> part.format(
... (pc.field("year") == 1862) & (pc.field("month") == "Jan")
... )
('1862/Jan', '')
The arrow Schema attached to the partitioning.
Copyright 2016-2026 Apache Software Foundation.
Apache Arrow, Arrow, Apache, the Apache logo, and the Apache Arrow project logo are either registered trademarks or trademarks of The Apache Software Foundation in the United States and other countries.
Created using Sphinx 9.1.0.
Built with the PyData Sphinx Theme 0.20.0.
| Web Proxy Viewer | New URL | Original Page |