Skip to content

Create Field

Description

A Field is composed of a name and a data type. Fields are used in Structs-datatypes and Schemas to represent everything of the Series/Column except the raw values.

Usage

pl$Field(name, datatype)

Arguments

name Field name
datatype DataType

Value

An object of class “RPolarsRField” containing its name and its data type.

Active Bindings

datatype

$datatype returns the data type of the Field.

$datatype = <RPolarsDataType> sets the data type of the Field.

name

$name returns the name of the Field.

$name = “new_name” sets the name of the Field.

Examples

library("polars")

field = pl$Field("city_names", pl$String)

field
#> Field {
#>     name: "city_names",
#>     dtype: String,
#> }
field$datatype
#> DataType: String
field$name
#> [1] "city_names"
# Set the new data type
field$datatype = pl$Categorical()
field$datatype
#> DataType: Categorical(
#>     None,
#>     Physical,
#> )
# Set the new name
field$name = "CityPoPulations"
field
#> Field {
#>     name: "CityPoPulations",
#>     dtype: Categorical(
#>         None,
#>         Physical,
#>     ),
#> }