pyarrow.field#
- pyarrow.field(name,type=None,nullable=None,metadata=None)#
Create a pyarrow.Field instance.
- Parameters:
- name
strorbytes Name of the field.Alternatively, you can also pass an object that implements the ArrowPyCapsule Protocol for schemas (has an
__arrow_c_schema__method).- type
pyarrow.DataTypeorstr Arrow datatype of the field or a string matching one.
- nullablebool, default
True Whether the field’s values are nullable.
- metadata
dict, defaultNone Optional field metadata, the keys and values must be coercible tobytes.
- name
- Returns:
- field
pyarrow.Field
- field
Examples
Create an instance of pyarrow.Field:
>>>importpyarrowaspa>>>pa.field('key',pa.int32())pyarrow.Field<key: int32>>>>pa.field('key',pa.int32(),nullable=False)pyarrow.Field<key: int32 not null>
>>>field=pa.field('key',pa.int32(),...metadata={"key":"Something important"})>>>fieldpyarrow.Field<key: int32>>>>field.metadata{b'key': b'Something important'}
Use the field to create a struct type:
>>>pa.struct([field])StructType(struct<key: int32>)
A str can also be passed for the type parameter:
>>>pa.field('key','int32')pyarrow.Field<key: int32>
On this page

