In R data.table, I can exclude columns like so
library(data.table)
foo <- data.table(x = c(1,2,3), y = c(4, 5, 6), z = c(7, 8, 9))
print(foo)
x y z
1: 1 4 7
2: 2 5 8
3: 3 6 9
# exclude one column
foo[, !"x"]
y z
1: 4 7
2: 5 8
3: 6 9
# exclude two columns
foo[, !c("x", "y")]
z
1: 7
2: 8
3: 9
How do I do the same thing in Python datatable?
import datatable as dt # v 1.0.0
foo = dt.Frame({'x': [1,2,3], 'y': [4,5,6], 'z': [7,8,9]})
print(foo)
| x y z
| int32 int32 int32
-- + ----- ----- -----
0 | 1 4 7
1 | 2 5 8
2 | 3 6 9
[3 rows x 3 columns]
# exclude one column
foo[:, !"x"] # error
foo[:, !["x"]] # error
foo[:, !f.x] # error
# exclude two columns
EDIT
Apologies for not explicitly stating this, but I'm aware of the obvious solution - do an inclusion statement, whereby I build a list of all the columns I want to include and use that as opposed to an exclusion statement whereby I use a list of columns to exclude. However, I find the inclusion technique awkward / cumbersome and less natural to read and write. As such, I'm specifically seeking an exclusion solution, like the one implemented in data.table.