DataFrame/Remove
remove columns or rows in a DataFrame
Calling Sequence
Parameters
Options
Description
Examples
Compatibility
Remove( df, index, options )
df
-
DataFrame
index
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
df≔123112324563789
The following removes the second column of the DataFrame:
Remove⁡df,2
2
13113246379
It is also possible to remove multiple columns of a DataFrame:
Remove⁡df,2,3
23
1112437
It is possible to remove rows in a DataFrame using the mode option:
Remove⁡df,1,mode=row
1
12324563789
The Remove command does not act inplace. In order to permanently remove a column, reassignment is needed.
df ≔ Remove⁡df,3
3
df≔12112245378
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.
Statistics:-BoxPlot⁡Remove⁡IrisData,Species,size=600,golden
5
The DataFrame/Remove command was introduced in Maple 2017.
For more information on Maple 2017 changes, see Updates in Maple 2017.
See Also
select, remove, and selectremove
Download Help Document
What kind of issue would you like to report? (Optional)