public static DataFrameColumnBase Clone(DataFrameColumnBase source) { switch (DataFrameTypeHelper.GetDataFrameType(source.DataType)) { case DataFrameType.Object: return(new DataFrameColumn <Object>((DataFrameColumn <Object>)(source))); case DataFrameType.Decimal: return(new DataFrameColumn <Decimal>((DataFrameColumn <Decimal>)(source))); case DataFrameType.Double: return(new DataFrameColumn <Double>((DataFrameColumn <Double>)(source))); case DataFrameType.Single: return(new DataFrameColumn <Single>((DataFrameColumn <Single>)(source))); case DataFrameType.Int64: return(new DataFrameColumn <Int64>((DataFrameColumn <Int64>)(source))); case DataFrameType.Int32: return(new DataFrameColumn <Int32>((DataFrameColumn <Int32>)(source))); case DataFrameType.Int16: return(new DataFrameColumn <Int16>((DataFrameColumn <Int16>)(source))); case DataFrameType.Byte: return(new DataFrameColumn <Byte>((DataFrameColumn <Byte>)(source))); case DataFrameType.SByte: return(new DataFrameColumn <SByte>((DataFrameColumn <SByte>)(source))); case DataFrameType.String: return(new DataFrameColumn <String>((DataFrameColumn <String>)(source))); case DataFrameType.Boolean: return(new DataFrameColumn <Boolean>((DataFrameColumn <Boolean>)(source))); } throw new ArgumentException("Unknown DataFrameType"); }
public static DataFrame FromDataTable(DataTable table) { var df = new DataFrame(); var rowCount = table.Rows.Count; foreach (DataColumn column in table.Columns) { var name = column.ColumnName; df.DefineNewColumn(name, DataFrameColumnFactory.Create(column.DataType, df, rowCount, 0)); } var columns = new DataFrameColumnBase[df.ColumnCount]; for (var i = 0; i < columns.Length; ++i) { columns[i] = df.GetColumn(i); } foreach (DataRow row in table.Rows) { for (var i = 0; i < columns.Length; ++i) { columns[i].AddObject(row[i]); } } return(df); }
internal abstract void AddColumn(DataFrameColumnBase column);