Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions src/Microsoft.Data.Analysis/IDataView.Extension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ public static DataFrame ToDataFrame(this IDataView dataView, long maxRows, param
{
dataFrameColumns.Add(new StringDataFrameColumn(dataViewColumn.Name));
}
else if (type is VectorDataViewType vectorType)
{
dataFrameColumns.Add(GetVectorDataFrame(vectorType, dataViewColumn.Name));
}
else
{
throw new NotSupportedException(String.Format(Microsoft.Data.Strings.NotSupportedColumnType, type.RawType.Name));
Expand Down Expand Up @@ -143,6 +147,66 @@ public static DataFrame ToDataFrame(this IDataView dataView, long maxRows, param

return new DataFrame(dataFrameColumns);
}

private static DataFrameColumn GetVectorDataFrame(VectorDataViewType vectorType, string name)
{
var itemType = vectorType.ItemType;

if (itemType.RawType == typeof(bool))
{
return new VBufferDataFrameColumn<bool>(name);
}
else if (itemType.RawType == typeof(byte))
{
return new VBufferDataFrameColumn<byte>(name);
}
else if (itemType.RawType == typeof(double))
{
return new VBufferDataFrameColumn<double>(name);
}
else if (itemType.RawType == typeof(float))
{
return new VBufferDataFrameColumn<Single>(name);
}
else if (itemType.RawType == typeof(int))
{
return new VBufferDataFrameColumn<Int32>(name);
}
else if (itemType.RawType == typeof(long))
{
return new VBufferDataFrameColumn<Int64>(name);
}
else if (itemType.RawType == typeof(sbyte))
{
return new VBufferDataFrameColumn<sbyte>(name);
}
else if (itemType.RawType == typeof(short))
{
return new VBufferDataFrameColumn<short>(name);
}
else if (itemType.RawType == typeof(uint))
{
return new VBufferDataFrameColumn<uint>(name);
}
else if (itemType.RawType == typeof(ulong))
{
return new VBufferDataFrameColumn<ulong>(name);
}
else if (itemType.RawType == typeof(ushort))
{
return new VBufferDataFrameColumn<ushort>(name);
}
else if (itemType.RawType == typeof(char))
{
return new VBufferDataFrameColumn<char>(name);
}
else if (itemType.RawType == typeof(decimal))
{
return new VBufferDataFrameColumn<decimal>(name);
}

throw new NotSupportedException(String.Format(Microsoft.Data.Strings.VectorSubTypeNotSupported, itemType.ToString()));
}
}

}
13 changes: 11 additions & 2 deletions src/Microsoft.Data.Analysis/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/Microsoft.Data.Analysis/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,8 @@
<data name="StreamDoesntSupportReading" xml:space="preserve">
<value>Stream doesn't support reading</value>
</data>
<data name="VectorSubTypeNotSupported" xml:space="preserve">
<value>Specified vector subtype {0} is not supported.</value>
<comment>{0} vectory subtype</comment>
</data>
</root>
Loading