@@ -116,6 +116,10 @@ public static DataFrame ToDataFrame(this IDataView dataView, long maxRows, param
116
116
{
117
117
dataFrameColumns . Add ( new StringDataFrameColumn ( dataViewColumn . Name ) ) ;
118
118
}
119
+ else if ( type is VectorDataViewType vectorType )
120
+ {
121
+ dataFrameColumns . Add ( GetVectorDataFrame ( vectorType , dataViewColumn . Name ) ) ;
122
+ }
119
123
else
120
124
{
121
125
throw new NotSupportedException ( String . Format ( Microsoft . Data . Strings . NotSupportedColumnType , type . RawType . Name ) ) ;
@@ -143,6 +147,66 @@ public static DataFrame ToDataFrame(this IDataView dataView, long maxRows, param
143
147
144
148
return new DataFrame ( dataFrameColumns ) ;
145
149
}
150
+
151
+ private static DataFrameColumn GetVectorDataFrame ( VectorDataViewType vectorType , string name )
152
+ {
153
+ var itemType = vectorType . ItemType ;
154
+
155
+ if ( itemType . RawType == typeof ( bool ) )
156
+ {
157
+ return new VBufferDataFrameColumn < bool > ( name ) ;
158
+ }
159
+ else if ( itemType . RawType == typeof ( byte ) )
160
+ {
161
+ return new VBufferDataFrameColumn < byte > ( name ) ;
162
+ }
163
+ else if ( itemType . RawType == typeof ( double ) )
164
+ {
165
+ return new VBufferDataFrameColumn < double > ( name ) ;
166
+ }
167
+ else if ( itemType . RawType == typeof ( float ) )
168
+ {
169
+ return new VBufferDataFrameColumn < Single > ( name ) ;
170
+ }
171
+ else if ( itemType . RawType == typeof ( int ) )
172
+ {
173
+ return new VBufferDataFrameColumn < Int32 > ( name ) ;
174
+ }
175
+ else if ( itemType . RawType == typeof ( long ) )
176
+ {
177
+ return new VBufferDataFrameColumn < Int64 > ( name ) ;
178
+ }
179
+ else if ( itemType . RawType == typeof ( sbyte ) )
180
+ {
181
+ return new VBufferDataFrameColumn < sbyte > ( name ) ;
182
+ }
183
+ else if ( itemType . RawType == typeof ( short ) )
184
+ {
185
+ return new VBufferDataFrameColumn < short > ( name ) ;
186
+ }
187
+ else if ( itemType . RawType == typeof ( uint ) )
188
+ {
189
+ return new VBufferDataFrameColumn < uint > ( name ) ;
190
+ }
191
+ else if ( itemType . RawType == typeof ( ulong ) )
192
+ {
193
+ return new VBufferDataFrameColumn < ulong > ( name ) ;
194
+ }
195
+ else if ( itemType . RawType == typeof ( ushort ) )
196
+ {
197
+ return new VBufferDataFrameColumn < ushort > ( name ) ;
198
+ }
199
+ else if ( itemType . RawType == typeof ( char ) )
200
+ {
201
+ return new VBufferDataFrameColumn < char > ( name ) ;
202
+ }
203
+ else if ( itemType . RawType == typeof ( decimal ) )
204
+ {
205
+ return new VBufferDataFrameColumn < decimal > ( name ) ;
206
+ }
207
+
208
+ throw new NotSupportedException ( String . Format ( Microsoft . Data . Strings . VectorSubTypeNotSupported , itemType . ToString ( ) ) ) ;
209
+ }
146
210
}
147
211
148
212
}
0 commit comments