ColumnTypes

ColumnTypes[tab]

gives the element types of the columns of the Tabular object tab.

ColumnTypes[tab,tsel]

gives the element types of the columns selected by tsel.

更多信息

  • ColumnTypes is typically used to obtain type information either to convert the type or decide what operations can be done. For instance, you cannot do date operations on strings.
  • For a Tabular object tab with named columns, ColumnTypes[tab,] returns a association of pairs coltype.
  • For a Tabular object tab with unnamed columns, ColumnTypes[tab,] returns a list of types.
  • The column type selector tsel can have one of these forms:
  • tpatttype pattern
    tclassnamed class of types
  • Possible type patterns tpatt include cases like "Integer*" or "Quantity"::["Real64",_].
  • Possible type classes tclass include:
  • "Numbers"number types
    "MachineNumbers"machine-sized number types
    "Reals"real-valued types, including integers
    "MachineReals"machine-sized real-valued types, including integers
    "Integers"integer types
    "MachineIntegers"machine-sized integer types
    "FloatingPoint"numbers with floating-point representation
    "MachineFloatingPoint"machine-sized real and complex numbers
    "FloatingPointReals"real numbers with floating-point representation
    "MachineFloatingPointReals"machine-sized real numbers
    "FloatingPointComplexes"complex numbers with floating-point representation
    "Lists"each element is a list

范例

打开所有单元关闭所有单元

基本范例  (3)

Find the types that are automatically selected for this Tabular object:

Find the types of the columns of reals:

Construct a Tabular object without keys from a numeric matrix:

Find the list of types of each column:

Scope  (15)

Numeric Types  (1)

Take a collection of integers or missing values:

By default, integers will be interpreted using the "Integer64" type in this machine:

Construct three columns with the same data but casting to different types of integers:

Check the stored types:

Boolean Type  (1)

Take a collection of Boolean or missing values:

ToTabular automatically interprets the data as a column of "Boolean" type:

String Type  (1)

Take a collection of words or missing values:

ToTabular automatically interprets the data as a column of "String" type:

Quantity Types  (2)

Take a collection of Quantity durations and missing values:

The values are stored using "Real64" magnitudes and a common unit of "Seconds":

For small enough Tabular objects, the original input data is cached by default and Normal recovers it:

Specify the magnitude type and unit to use:

The original input was not cached:

Quantities of different dimensions can be stored using the "InertExpression" type:

Trying to impose a specific "Quantity" type will result in missing values:

Date & Time Types  (3)

Take a collection of dates:

Create a Tabular object with automatic type detection:

Specify a type to convert to granularity "Day" when dates are extracted:

Take a collection of times:

Create a Tabular object with automatic type detection:

Specify a type to convert to granularity "Hour" when times are extracted:

Specify dates with a different calendar:

Categorical Type  (2)

Take a collection of strings:

ToTabular automatically interprets the data as a column of "String" type:

Explicitly specify a "Categorical" type for the column, categorizing the data:

Extract the categories:

Split a gene sequence into a list of the nucleotide bases:

Create a Tabular object with specific categories of the nucleotide bases:

Visualize the beginning of the sequence:

Categorical Ordered Type  (1)

Take a collection of sizes:

Create a Tabular object with automatic type detection:

The automatically detected type is "String":

Specify the "CategoricalOrdered" type providing the list categories, which defines the ordering:

Lists & Tuples  (2)

Take a collection of integer tuples:

Specify the type of the elements of the tuples:

Take a collection of tuples of objects of various types:

Create a Tabular object with automatic type detection:

Specify the types of the elements of the tuples:

General Expressions  (1)

Take a collection of regions:

Creating a Tabular object assigns type "Expression" to general Wolfram Language expressions:

Column Selectors  (1)

Get column types for all columns:

Extract column types for two columns:

Extract columns of Boolean type:

Extract columns of any integer type:

Extract columns that are either string or Boolean:

Applications  (1)

Create a TabularRow with automatic input type detection:

Column types:

Specify types:

Column types:

Wolfram Research (2025),ColumnTypes,Wolfram 语言函数,https://reference.wolfram.com/language/ref/ColumnTypes.html.

文本

Wolfram Research (2025),ColumnTypes,Wolfram 语言函数,https://reference.wolfram.com/language/ref/ColumnTypes.html.

CMS

Wolfram 语言. 2025. "ColumnTypes." Wolfram 语言与系统参考资料中心. Wolfram Research. https://reference.wolfram.com/language/ref/ColumnTypes.html.

APA

Wolfram 语言. (2025). ColumnTypes. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/ColumnTypes.html 年

BibTeX

@misc{reference.wolfram_2025_columntypes, author="Wolfram Research", title="{ColumnTypes}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/ColumnTypes.html}", note=[Accessed: 15-January-2025 ]}

BibLaTeX

@online{reference.wolfram_2025_columntypes, organization={Wolfram Research}, title={ColumnTypes}, year={2025}, url={https://reference.wolfram.com/language/ref/ColumnTypes.html}, note=[Accessed: 15-January-2025 ]}