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); }
public DataFrame Clone() { var df = new DataFrame(); for (var i = 0; i < ColumnCount; ++i) { df.DefineNewColumn(ColumnNames[i], DataFrameColumnFactory.Clone(GetColumn(i))); } return(df); }
public static DataFrame CreateLike(DataFrame source, int capacity, int fillSize) { var df = new DataFrame(); foreach (var name in source.ColumnNames) { df.DefineNewColumn(name, DataFrameColumnFactory.Create(source.GetColumn(name).DataType, df, capacity, fillSize)); } return(df); }