@@ -101,7 +101,7 @@ function MMI.selectcols(::FI, ::Val{:table}, X, c::Union{Symbol, Integer})
101
101
return Tables. getcolumn (cols, c)
102
102
end
103
103
104
- function MMI. selectcols (:: FI , :: Val{:table} , X, c:: Union{Colon, AbstractArray} )
104
+ function MMI. selectcols (:: FI , :: Val{:table} , X, c)
105
105
if isdataframe (X)
106
106
return X[! , c]
107
107
else
@@ -115,18 +115,28 @@ end
115
115
# utils for `select`*
116
116
117
117
# project named tuple onto a tuple with only specified `labels` or indices:
118
- function project (t:: NamedTuple , labels:: AbstractArray{Symbol} )
118
+ function project (t:: NamedTuple , labels:: Union{ AbstractArray{Symbol},NTuple{<:Any,Symbol} } )
119
119
return NamedTuple {tuple(labels...)} (t)
120
120
end
121
121
122
122
project (t:: NamedTuple , label:: Colon ) = t
123
123
project (t:: NamedTuple , label:: Symbol ) = project (t, [label,])
124
124
project (t:: NamedTuple , i:: Integer ) = project (t, [i,])
125
125
126
- function project (t:: NamedTuple , indices:: AbstractArray{<:Integer} )
126
+ function project (
127
+ t:: NamedTuple ,
128
+ indices:: AbstractArray{<:Integer} ,
129
+ )
127
130
return NamedTuple {tuple(keys(t)[indices]...)} (tuple ([t[i] for i in indices]. .. ))
128
131
end
129
132
133
+ function project (
134
+ t:: NamedTuple ,
135
+ indices:: NTuple{<:Any,<:Integer} ,
136
+ )
137
+ return NamedTuple {tuple(keys(t)[[indices...]]...)} (tuple ([t[i] for i in indices]. .. ))
138
+ end
139
+
130
140
# utils for selectrows
131
141
typename (X) = split (string (supertype (typeof (X))), ' .' )[end ]
132
142
isdataframe (X) = typename (X) == " AbstractDataFrame"
0 commit comments