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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more