withColumnsDropped method
A new data frame without the selected columns.
Example:
print(iris.withHead(3));
print(iris.withHead(3).withColumnsDropped(["petal_length", "species"]));
.--.------------.-----------.------------.-----------.--------.
|id|sepal_length|sepal_width|petal_length|petal_width|species |
:--+------------+-----------+------------+-----------+--------:
|1 |5.1 |3.5 |1.4 |0.2 |setosa |
|2 |4.9 |3.0 |1.4 |0.2 |setosa |
|3 |4.7 |3.2 |1.3 |0.2 |setosa |
'--'------------'-----------'------------'-----------'--------'
.--.------------.-----------.-----------.
|id|sepal_length|sepal_width|petal_width|
:--+------------+-----------+-----------:
|1 |5.1 |3.5 |0.2 |
|2 |4.9 |3.0 |0.2 |
|3 |4.7 |3.2 |0.2 |
'--'------------'-----------'-----------'
Implementation
DataFrame withColumnsDropped(Iterable<String> columnNames) => withColumns([
...numericColumns.keys
.where((columnName) => !columnNames.contains(columnName)),
...categoricColumns.keys
.where((columnName) => !columnNames.contains(columnName))
]);