 Column Labels - Maple Help

DataFrame/ColumnLabels

obtain column labels of a DataFrame

DataFrame/RowLabels

obtain row labels of a DataFrame

DataFrame/SubsColumnLabel

create a DataFrame with a different column label

DataFrame/SubsRowLabel

create a DataFrame with a different row label Calling Sequence ColumnLabels(DF) ColumnLabels(DF, i) SubsColumnLabel(DF, i, label) RowLabels(DF) RowLabels(DF, i) SubsRowLabel(DF, i, label) Parameters

 DF - a DataFrame object i - a nonzero integer or valid row or column label label - a new label Description

 • The ColumnLabels command returns the list of column labels for a DataFrame object, or a single column label. A single label is specified by its position.
 • The RowLabels command returns the list of row labels for a DataFrame object, or a single row label. A single label is specified by its position.
 • The SubsColumnLabel command creates a DataFrame object with a different column label.
 • The SubsRowLabel command creates a DataFrame object with a different row label.
 • Note: the SubsColumnLabel and SubsRowLabel commands do not modify the given DataFrame object DF - they just return new DataFrame objects. See the Examples section below.
 • If i is a negative integer, it specifies the position counting from the end. For example, -2 specifies the label before last. Examples

 > $\mathrm{df}≔\mathrm{DataFrame}\left(\left[\left[5,6,8\right],\left[8,9,1\right],\left[9,6,0\right],\left[2,5,9\right]\right],\mathrm{columns}=\left[A,B,C,\mathrm{D}\right],\mathrm{rows}=\left[a,b,c\right]\right)$
 ${\mathrm{df}}{≔}\left[\begin{array}{ccccc}{}& {A}& {B}& {C}& {\mathrm{D}}\\ {a}& {5}& {8}& {9}& {2}\\ {b}& {6}& {9}& {6}& {5}\\ {c}& {8}& {1}& {0}& {9}\end{array}\right]$ (1)
 > $\mathrm{ColumnLabels}\left(\mathrm{df}\right)$
 $\left[{A}{,}{B}{,}{C}{,}{\mathrm{D}}\right]$ (2)
 > $\mathrm{RowLabels}\left(\mathrm{df}\right)$
 $\left[{a}{,}{b}{,}{c}\right]$ (3)
 > $\mathrm{ColumnLabels}\left(\mathrm{df},2\right)$
 ${B}$ (4)
 > $\mathrm{RowLabels}\left(\mathrm{df},-1\right)$
 ${c}$ (5)

The statements below does not modify $\mathrm{df}$.

 > $\mathrm{df2}≔\mathrm{SubsColumnLabel}\left(\mathrm{df},3,X\right)$
 ${\mathrm{df2}}{≔}\left[\begin{array}{ccccc}{}& {A}& {B}& {X}& {\mathrm{D}}\\ {a}& {5}& {8}& {9}& {2}\\ {b}& {6}& {9}& {6}& {5}\\ {c}& {8}& {1}& {0}& {9}\end{array}\right]$ (6)
 > $\mathrm{ColumnLabels}\left(\mathrm{df}\right)$
 $\left[{A}{,}{B}{,}{C}{,}{\mathrm{D}}\right]$ (7)
 > $\mathrm{ColumnLabels}\left(\mathrm{df2}\right)$
 $\left[{A}{,}{B}{,}{X}{,}{\mathrm{D}}\right]$ (8)
 > $\mathrm{SubsRowLabel}\left(\mathrm{df},1,z\right)$
 $\left[\begin{array}{ccccc}{}& {A}& {B}& {C}& {\mathrm{D}}\\ {z}& {5}& {8}& {9}& {2}\\ {b}& {6}& {9}& {6}& {5}\\ {c}& {8}& {1}& {0}& {9}\end{array}\right]$ (9)
 > $\mathrm{SubsRowLabel}\left(\mathrm{df},a,S\right)$
 $\left[\begin{array}{ccccc}{}& {A}& {B}& {C}& {\mathrm{D}}\\ {S}& {5}& {8}& {9}& {2}\\ {b}& {6}& {9}& {6}& {5}\\ {c}& {8}& {1}& {0}& {9}\end{array}\right]$ (10)

We can make the change apply to $\mathrm{df}$ by assigning the result to $\mathrm{df}$.

 > $\mathrm{df}≔\mathrm{SubsColumnLabel}\left(\mathrm{df},3,X\right)$
 ${\mathrm{df}}{≔}\left[\begin{array}{ccccc}{}& {A}& {B}& {X}& {\mathrm{D}}\\ {a}& {5}& {8}& {9}& {2}\\ {b}& {6}& {9}& {6}& {5}\\ {c}& {8}& {1}& {0}& {9}\end{array}\right]$ (11)
 > $\mathrm{df}≔\mathrm{SubsRowLabel}\left(\mathrm{df},1,z\right)$
 ${\mathrm{df}}{≔}\left[\begin{array}{ccccc}{}& {A}& {B}& {X}& {\mathrm{D}}\\ {z}& {5}& {8}& {9}& {2}\\ {b}& {6}& {9}& {6}& {5}\\ {c}& {8}& {1}& {0}& {9}\end{array}\right]$ (12)
 > $\mathrm{ColumnLabels}\left(\mathrm{df}\right)$
 $\left[{A}{,}{B}{,}{X}{,}{\mathrm{D}}\right]$ (13)
 > $\mathrm{RowLabels}\left(\mathrm{df}\right)$
 $\left[{z}{,}{b}{,}{c}\right]$ (14) Compatibility

 • The DataFrame/ColumnLabels, DataFrame/RowLabels, DataFrame/SubsColumnLabel and DataFrame/SubsRowLabel commands were introduced in Maple 2016.