Append a DataFrame to another DataFrame - Maple Help

# Online Help

###### All Products    Maple    MapleSim

DataFrame/Append

append a DataFrame or DataSeries to a DataFrame

 Calling Sequence Append( df1, df2, opts )

Parameters

 df1 - : a DataFrame object df2 - : a DataFrame or DataSeries object, a list, or a Vector opts - : (optional) an option of the form mode = m, where m is one of row or rows or column or columns or merge or overwrite, and/or an option of the form label = L

Description

 • The Append( df1, df2 ) command appends the DataFrame or DataSeries object df2 to the DataFrame df1, and returns the newly constructed DataFrame. It does not modify df1.
 • By specifying the option $\mathrm{mode}=\mathrm{row}$ or $\mathrm{mode}=\mathrm{rows}$ (the two are equivalent), you instruct the Append command to append df2 as new rows. In this mode, if df2 is a DataFrame, df1 and df2 must have disjoint row labels. Column labels may be shared, and common columns will be aligned. If df2 is a DataSeries, then its labels will be aligned with the column labels of df1. If df2 is a list or a Vector, then its entries will form the new row in the same order as in df2 itself.
 This mode is the default if df2 is a DataFrame.
 • By specifying the option $\mathrm{mode}=\mathrm{column}$ or $\mathrm{mode}=\mathrm{columns}$ (the two are equivalent), the Append command is made to work in column mode. In this mode, if df2 is a DataFrame, then df1 and df2 must have disjoint column labels, and row labels will be aligned. If df2 is a DataSeries object, it will be added as a new column, and its labels will be aligned with the row labels of df1. If df2 is a list or a Vector, then its entries will form the new column in the same order as in df2 itself.
 This mode is the default if df2 is a DataSeries, a list, or a Vector.
 • By specifying the option $\mathrm{mode}=\mathrm{merge}$ or $\mathrm{mode}=\mathrm{overwrite}$, you select a mode that allows for overlap between both row and column labels. With $\mathrm{mode}=\mathrm{merge}$, those values will come from df1; by specifying $\mathrm{mode}=\mathrm{overwrite}$, they come from df2. (In the case of $\mathrm{mode}=\mathrm{overwrite}$, the order of labels in the result will be based on the order in df2; this is different from all other modes, where it is based on the order in df1.) These modes can only be used if df2 is a DataFrame object.
 • If df2 is a DataSeries, then the label for the new row (in row mode) or column (in column mode) is, by default, an arbitrary positive integer. If the label option is specified, its value is used instead.
 If df2 is a list or a Vector, then the same rules apply. Also, the number of entries of df2 must be the same as the number of rows (in column mode) or columns (in row mode) of df1.

Examples

 > $\mathrm{df1}≔\mathrm{DataFrame}\left(⟨⟨1|2|3⟩,⟨4|5|6⟩,⟨7|8|9⟩⟩,'\mathrm{columns}'=\left['A','B','C'\right],'\mathrm{rows}'=\left['a','b','c'\right]\right)$
 ${\mathrm{df1}}{≔}\left[\begin{array}{cccc}{}& {A}& {B}& {C}\\ {a}& {1}& {2}& {3}\\ {b}& {4}& {5}& {6}\\ {c}& {7}& {8}& {9}\end{array}\right]$ (1)
 > $\mathrm{df2}≔\mathrm{DataFrame}\left(⟨⟨\frac{1}{2}|\frac{2}{3}|\frac{3}{4}⟩,⟨\frac{4}{5}|\frac{5}{6}|\frac{6}{7}⟩,⟨\frac{7}{8}|\frac{8}{9}|\frac{9}{10}⟩⟩,'\mathrm{columns}'=\left['B','C','\mathrm{D}'\right],'\mathrm{rows}'=\left['d','e','f'\right]\right)$
 ${\mathrm{df2}}{≔}\left[\begin{array}{cccc}{}& {B}& {C}& {\mathrm{D}}\\ {d}& \frac{{1}}{{2}}& \frac{{2}}{{3}}& \frac{{3}}{{4}}\\ {e}& \frac{{4}}{{5}}& \frac{{5}}{{6}}& \frac{{6}}{{7}}\\ {f}& \frac{{7}}{{8}}& \frac{{8}}{{9}}& \frac{{9}}{{10}}\end{array}\right]$ (2)
 > $\mathrm{Append}\left(\mathrm{df1},\mathrm{df2}\right)$
 $\left[\begin{array}{ccccc}{}& {A}& {B}& {C}& {\mathrm{D}}\\ {a}& {1}& {2}& {3}& {\mathrm{undefined}}\\ {b}& {4}& {5}& {6}& {\mathrm{undefined}}\\ {c}& {7}& {8}& {9}& {\mathrm{undefined}}\\ {d}& {\mathrm{undefined}}& \frac{{1}}{{2}}& \frac{{2}}{{3}}& \frac{{3}}{{4}}\\ {e}& {\mathrm{undefined}}& \frac{{4}}{{5}}& \frac{{5}}{{6}}& \frac{{6}}{{7}}\\ {f}& {\mathrm{undefined}}& \frac{{7}}{{8}}& \frac{{8}}{{9}}& \frac{{9}}{{10}}\end{array}\right]$ (3)

Compatibility

 • The DataFrame/Append command was introduced in Maple 2016.
 • For more information on Maple 2016 changes, see Updates in Maple 2016.

 See Also