Published
Edited
Jan 24, 2020
15 stars
Insert cell
Insert cell
arrow = require('@apache-arrow/es5-umd@0.15.1')
Insert cell
Insert cell
Insert cell
Insert cell
//autogenerates backing buffer
hundred_uint64 = arrow.util.Uint64.fromNumber(100)
Insert cell
Insert cell
hundred_uint64.buffer
Insert cell
Insert cell
arrow.util.Uint64.fromNumber(101010101010101).buffer
Insert cell
Insert cell
hundred_int128 = new arrow.util.Int128(new Uint32Array([100,0,0,0]))
Insert cell
Insert cell
arrow.util.Uint64.multiply(hundred_uint64, hundred_uint64).buffer
Insert cell
Insert cell
int32_vector = arrow.Int32Vector.from([1,2,3])
Insert cell
Insert cell
int64_vector = arrow.Int64Vector.from([1,2,3])
Insert cell
Insert cell
int32_with_nulls_vector = arrow.Int64Vector.from([null,null,22])
Insert cell
Insert cell
my_table = arrow.Table.new(
arrow.Column.new('my_col_1', int32_vector),
arrow.Column.new('my_col_2', int64_vector),
arrow.Column.new('my_col_3', int32_with_nulls_vector))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
int64_arr2 = arrow.IntVector.from(new Int32Array([2,3, 555,0, 1,0]), true)
Insert cell
Insert cell
int64_arr2.length
Insert cell
my_table2 = arrow.Table.new(
[int64_arr2,int64_arr2],
['my_col_1', 'my_col_2'])
Insert cell
Insert cell
Insert cell
Insert cell
dict_vector = arrow.Vector.from({
values: ['apple', 'apple', null, 'banana', null, 'orange', 'apple'],
type: new arrow.Dictionary(new arrow.Utf8(), new arrow.Int32())
/* , highWaterMark: Infinity */
})
Insert cell
Insert cell
dict_vector.dictionary.data
Insert cell
Insert cell
nestedJsonValues = [
{"nick": "The butcher of Anderson Station",
"full": {"first": "Fredrick", "last": "Johnson"}},
{"nick": "Bobbie",
"full": {"first": "Roberta", "last": "Draper"}}
]
Insert cell
Insert cell
nestedIdentityType = new arrow.Struct([
arrow.Field.new({ name: "nick", type: new arrow.Utf8() }),
arrow.Field.new({
name: "full",
type: new arrow.Struct([
arrow.Field.new({ name: "first", type: new arrow.Utf8() }),
arrow.Field.new({ name: "last", type: new arrow.Utf8() })
])
})
])
Insert cell
Insert cell
names_vector = arrow.Vector.from({
type: nestedIdentityType,
/* highWaterMark: Infinity,*/
values: nestedJsonValues
})
Insert cell
Insert cell
Insert cell
Insert cell
md`${getMarkdown(function () {

function getChild(vector, name) {
return vector.getChildAt((vector.type.children || []).findIndex((f) => f.name === name));
}
return arrow.Table.new({
'fruit': dict_vector.slice(0,names_table.length),
'as_struct': names_table.getColumn('my_col_1'),
'sliced_nick': getChild(names_table.getColumn('my_col_1'), 'nick')
});
}())}`
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more