 DataFrame - Maple Help

Overview of DataFrames Description

 • A DataFrame is a two-dimensional data container, similar to a Matrix, but which can contain heterogeneous data, and for which symbolic names may be associated with the rows and columns. The column labels need to be unique, as do the row labels. Indexing

 • Each column of a DataFrame is a DataSeries, and the column labels may be used to refer to the corresponding column.
 > df := DataFrame( < 1, 2, 3; 4, 5, 6 >, 'rows' = [ 'a', 'b' ], 'columns' = [ 'A', 'B', 'C' ] );
 ${\mathrm{df}}{≔}\left[\begin{array}{cccc}{}& {A}& {B}& {C}\\ {a}& {1}& {2}& {3}\\ {b}& {4}& {5}& {6}\end{array}\right]$ (1)
 > type( df[ 'B' ], DataSeries );
 ${\mathrm{true}}$ (2)
 • Since each column is a DataSeries, you can index hierarchically into the columns of a DataFrame to extract individual data elements.
 > df[ 'B' ][ 1 ];
 ${2}$ (3)
 > df[ 'B' ][ 'b' ];
 ${5}$ (4)
 • However, you can also select individual data items by specifying the desired row and column indices directly.  (Row and column indices may be either numeric, by position, or symbolic.)
 > df[ 1, 2 ];
 ${2}$ (5)
 > df[ 'a', 'B' ];
 ${2}$ (6)
 • You can use a range or list to select specified columns. In the case of a list, they can come in any desired order.
 > df[ 'A' .. 'B'];
 $\left[\begin{array}{ccc}{}& {A}& {B}\\ {a}& {1}& {2}\\ {b}& {4}& {5}\end{array}\right]$ (7)
 > df[ [ 'B', 'C', 'A' ] ];
 $\left[\begin{array}{cccc}{}& {B}& {C}& {A}\\ {a}& {2}& {3}& {1}\\ {b}& {5}& {6}& {4}\end{array}\right]$ (8)