// NewDataFrame creates a new data frame from the provided schema and arrays.
NewDataFrame creates a new data frame from the provided schema and arrays.
// NewDataFrame creates a new data frame from the provided schema and arrays .
func NewDataFrame(mem memory.Allocator, schema *arrow.Schema, arrs []array.Interface) (*DataFrame, error) {
	df := &DataFrame{
		refs:    1,
		mem:     mem,
		schema:  schema,
		rows:    -1,
		mutator: NewMutator(mem),
	}
	if df.rows < 0 {
		switch len(arrs) {
		case 0:
			df.rows = 0
		default:
			df.rows = int64(arrs[0].Len())
		}
	}
	if df.schema == nil {
		return nil, fmt.Errorf("dataframe: nil schema")
	}
	if len(df.schema.Fields()) != len(arrs) {
		return nil, fmt.Errorf("dataframe: inconsistent schema/arrays")
	}
	for i, arr := range arrs {
		ft := df.schema.Field(i)
		if fmt.Sprintf("%s", arr.DataType()) != fmt.Sprintf("%s", ft.Type) {
			return nil, fmt.Errorf("dataframe: column %q is inconsitent with schema (%s != %s)", ft.Name, arr.DataType(), ft.Type)
		}
		if int64(arr.Len()) < df.rows {
			return nil, fmt.Errorf("dataframe: column %q expected length >= %d but got length %d", ft.Name, df.rows, arr.Len())
		}
	}
	df.cols = make([]array.Column, len(arrs))
	for i := range arrs {
		func(i int) {
			chunk := array.NewChunked(arrs[i].DataType(), []array.Interface{arrs[i]})
			defer chunk.Release()
			col := array.NewColumn(df.schema.Field(i), chunk)
			df.cols[i] = *col
		}(i)
	}
	return df, nil
}
func NewDataFrame ( mem memory . Allocator , schema * arrow . Schema , arrs [ ] array . Interface ) ( * DataFrame , error ) { df := & DataFrame { refs : 1 , mem : mem , schema : schema , rows : - 1 , mutator : NewMutator ( mem ) , } if df . rows < 0 { switch len ( arrs ) { case 0 : df . rows = 0 default : df . rows = int64 ( arrs [ 0 ] . Len ( ) ) } } if df . schema == nil { return nil , fmt . Errorf ( " " ) } if len ( df . schema . Fields ( ) ) != len ( arrs ) { return nil , fmt . Errorf ( " " ) } for i , arr := range arrs { ft := df . schema . Field ( i ) if fmt . Sprintf ( " " , arr . DataType ( ) ) != fmt . Sprintf ( " " , ft . Type ) { return nil , fmt . Errorf ( " " , ft . Name , arr . DataType ( ) , ft . Type ) } if int64 ( arr . Len ( ) ) < df . rows { return nil , fmt . Errorf ( " " , ft . Name , df . rows , arr . Len ( ) ) } } df . cols = make ( [ ] array . Column , len ( arrs ) ) for i := range arrs { func ( i int ) { chunk := array . NewChunked ( arrs [ i ] . DataType ( ) , [ ] array . Interface { arrs [ i ] } ) defer chunk . Release ( ) col := array . NewColumn ( df . schema . Field ( i ) , chunk ) df . cols [ i ] = * col } ( i ) } return df , nil }
NewDataFrame creates a new data frame from the provided schema and arrays.
NewDataFrame creates a new data frame from the provided schema and arrays .