DeleteColumns

DeleteColumns[tab,cspec]

deletes the columns specified by cspec from the tabular data tab.

DeleteColumns[cspec]

represents an operator form of DeleteColumns that can be applied to tabular data.

Details

  • DeleteColumns is also known as remove columns.
  • DeleteColumns is typically used to eliminate columns from tabular data to streamline subsequent processing.
  • Possible forms of tabular data tab include:
  • Tabular[]type-consistent tabular data
    Dataset[]general hierarchical data
    {assoc1,assoc2,}a list of associations of common keys
    matrixa matrix
  • Possible column specifications cspec include:
  • name or Key[name] or ExtendedKey[]named column
    indinteger indexed column
    {col1,}several columns
    cmin;;cmax;;stepa Span of columns

Examples

open allclose all

Basic Examples  (1)

Delete a single column from a Tabular object:

Delete multiple columns:

Scope  (8)

Delete a column from a Tabular object:

Delete two columns:

Use column indices instead:

Or a Span specification:

It is possible to delete all columns from a Tabular object:

The result has the original number of rows and zero columns:

Delete a column from a Dataset object:

Delete two columns:

Delete a column from a list of associations with common keys:

Delete two columns:

Delete a column from a matrix:

Delete the first and the last columns:

Delete a span of columns:

Use the operator form of DeleteColumns:

Take a Tabular object:

Delete one column by specifying its column key:

Column keys can also be wrapped in Key or ExtendedKey:

Take a Tabular object with extended column keys:

Delete a column by specifying its complete extended key:

The last subkey of the extended key can be specified if it uniquely identifies the column:

Properties & Relations  (5)

The action of DeleteColumns is equivalent to Part extraction of the remaining columns:

Deleting an empty list of columns returns the original object:

DeleteColumns is a special version of TransformColumns:

Delete the selected column using DeleteColumns:

Use TransformColumns to set the selected column to Nothing:

DeleteColumns is a complementary operation to ConstructColumns:

Extract one column:

Take a Tabular object and extract a column:

Delete the same column from the Tabular object:

Use InsertColumns to insert the column after column "a" again, now using key "B":

Wolfram Research (2025), DeleteColumns, Wolfram Language function, https://reference.wolfram.com/language/ref/DeleteColumns.html.

Text

Wolfram Research (2025), DeleteColumns, Wolfram Language function, https://reference.wolfram.com/language/ref/DeleteColumns.html.

CMS

Wolfram Language. 2025. "DeleteColumns." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/DeleteColumns.html.

APA

Wolfram Language. (2025). DeleteColumns. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DeleteColumns.html

BibTeX

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

BibLaTeX

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