remove columns or rows in a DataFrame
Remove( df, index, options )
name, string, integer or list; specifies the index of the column (or columns) to remove from the DataFrame
mode : name; specifies whether to remove columns or rows. The default is column. This option is entered in the form mode = m, where m is one of column, columns, row, or rows.
The Remove command removes a chosen column or row or a list of columns or rows from a DataFrame.
The Remove command is used to remove columns from a DataFrame:
df ≔ DataFrame⁡1|2|3,4|5|6,7|8|9
The following removes the second column of the DataFrame:
It is also possible to remove multiple columns of a DataFrame:
It is possible to remove rows in a DataFrame using the mode option:
The Remove command does not act inplace. In order to permanently remove a column, reassignment is needed.
df ≔ Remove⁡df,3
The Remove command is helpful when dealing with DataFrames that have a mixture of non-numeric and numeric columns. For example, the Iris data set has 4 columns of numeric data and one column of strings.
IrisData ≔ Import⁡datasets/iris.csv,base=datadir
Attempting to plot or run any statistical analysis on this dataset as is will often result in an error due to the non-numeric data. Removing the non-numeric data for analysis avoids this issue.
The DataFrame/Remove command was introduced in Maple 2017.
For more information on Maple 2017 changes, see Updates in Maple 2017.
select, remove, and selectremove
Download Help Document