Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

Sliceup Demo

node v10.24.1
version: 1.0.0
endpointsharetweet
const {Sliceup, max, mul, min, count, bar, time, last, sums} = require("sliceup") const sliceup = new Sliceup('demo.sliceup.co') // create orders table await sliceup.create({ 'name': 'orders', 'columns': [ {'name': 'time', 'type': 'time'}, {'name': 'qty', 'type': 'int'}, {'name': 'price', 'type': 'float'} ], 'recreate': true }) // now, let's insert data into our new table await sliceup.insert({ 'name': 'orders', 'rows': [ {'time': '00:00:00', 'qty': 2, 'price': 9.0}, {'time': '00:30:09', 'qty': 2, 'price': 2.0}, {'time': '01:45:01', 'qty': 4, 'price': 1.0}, {'time': '12:10:33', 'qty': 10, 'price': 16.0}, {'time': '16:00:09', 'qty': 4, 'price': 8.0}, {'time': '22:00:00', 'qty': 4, 'price': 23.0}, {'time': '22:31:49', 'qty': 4, 'price': 45.0}, {'time': '22:59:19', 'qty': 4, 'price': 17.0}, ] })
// now query the data let data = await sliceup.query({ 'select': ['time', 'qty', 'price'], 'from': 'orders' }) data.visualize()
// now query the data for summary statistics data = await sliceup.query({ 'select': [max('time'), min('time'), min('qty'), max('qty'), min('price'), max('price')], 'from': 'orders' }) data.visualize()
// now slice the data into hour buckets, and take last price in each bucket to create a time series data = await sliceup.query({ 'select': [last('price')], 'by': [bar('time', time(1,0,0))], 'from': 'orders' }) data.visualize()
// slice and group the quantity by bars of 2 and count how many records in each bucket to create a histogram data = await sliceup.query({ 'select': [count('price')], 'by': [bar('qty', 2)], 'from': 'orders' }) data.visualize()
// provide cumulative sum of quantities data = await sliceup.query({ 'select': ['time', 'qty', sums('qty')], 'from': 'orders' }) data.visualize()
Loading…

no comments

    sign in to comment