withColumnsWhere method
A new data frame with only the columns whose names meet predicate.
Example:
print(iris.withHead(3));
print(iris.withHead(3).withColumnsWhere((c) => c.contains("sepal")));
.--.------------.-----------.------------.-----------.--------.
|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 |
'--'------------'-----------'------------'-----------'--------'
.------------.-----------.
|sepal_length|sepal_width|
:------------+-----------:
|5.1 |3.5 |
|4.9 |3.0 |
|4.7 |3.2 |
'------------'-----------'
Implementation
DataFrame withColumnsWhere(bool Function(String) predicate) => withColumns(
[...numericColumns.keys, ...categoricColumns.keys].where(predicate));