UNPKG

data-forge

Version:

JavaScript data transformation and analysis toolkit inspired by Pandas and LINQ.

1 lines 237 kB
var dataForge=function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=2)}([function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__values||function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}},u=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),u=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)u.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return u},a=this&&this.__spread||function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(u(arguments[t]));return e},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var c=r(7),l=r(8),f=r(9),h=r(10),p=r(11),d=r(12),y=r(13),m=r(14),v=r(15),D=r(37),g=r(16),w=r(17),b=r(18),E=r(41),F=r(43),C=r(19),x=r(5),A=r(20),S=r(21),_=r(22),B=s(r(23)),I=r(1),O=s(r(3)),k=s(r(27));O.default.extend(k.default);var N,j=r(4),M=r(2),P=s(r(77)),T=r(26);!function(e){e.Start="start",e.End="end"}(N=t.WhichIndex||(t.WhichIndex={}));var R=function(){function e(t){if(this.configFn=null,this.content=null,this.indexedContent=null,t){var r=t;if(void 0!==r.getTypeCode){var n=r.getTypeCode();if("dataframe"===n||"series"===n)return void(void 0!==r.content?this.content=r.content:this.configFn=r.configFn)}j.isFunction(t)?this.configFn=t:e.isIterator(t)?this.content=e.initFromIterator(t):e.isIterable(t)?this.content=e.initFromIterable(t):this.content=e.initFromConfig(t)}else this.content=e.initEmpty()}return e.initFromIterator=function(t){return e.initFromIterable(new T.CachedIteratorIterable(t))},e.initFromIterable=function(t){return{index:e.defaultCountIterable,values:t,pairs:new f.MultiIterable([e.defaultCountIterable,t]),isBaked:!0}},e.initEmpty=function(){return{index:e.defaultEmptyIterable,values:e.defaultEmptyIterable,pairs:e.defaultEmptyIterable,isBaked:!0}},e.isIterator=function(e){return j.isObject(e)&&j.isFunction(e.next)},e.isIterable=function(e){return j.isArray(e)||j.isObject(e)&&j.isFunction(e[Symbol.iterator])},e.checkIterable=function(t,r){if(!e.isIterable(t))throw new Error("Expected '"+r+"' field of Series config object to be an array of values or an iterable of values.")},e.initFromConfig=function(t){var r,n,i,o=!1;return t.pairs&&(e.isIterator(t.pairs)?i=new T.CachedIteratorIterable(t.pairs):(e.checkIterable(t.pairs,"pairs"),i=t.pairs)),t.index?e.isIterator(t.index)?r=new T.CachedIteratorIterable(t.index):(e.checkIterable(t.index,"index"),r=t.index):r=i?new A.ExtractElementIterable(i,0):e.defaultCountIterable,t.values?e.isIterator(t.values)?n=new T.CachedIteratorIterable(t.values):(e.checkIterable(t.values,"values"),n=t.values):n=i?new A.ExtractElementIterable(i,1):e.defaultEmptyIterable,i||(i=new f.MultiIterable([r,n])),void 0!==t.baked&&(o=t.baked),{index:r,values:n,pairs:i,isBaked:o}},e.prototype.lazyInit=function(){null===this.content&&null!==this.configFn&&(this.content=e.initFromConfig(this.configFn()))},e.prototype.getContent=function(){return this.lazyInit(),this.content},e.prototype.getRowByIndex=function(e){if(!this.indexedContent){this.indexedContent=new Map;try{for(var t=o(this.getContent().pairs),r=t.next();!r.done;r=t.next()){var n=r.value;this.indexedContent.set(n[0],n[1])}}catch(e){i={error:e}}finally{try{r&&!r.done&&(u=t.return)&&u.call(t)}finally{if(i)throw i.error}}}return this.indexedContent.get(e);var i,u},e.prototype[Symbol.iterator]=function(){return this.getContent().values[Symbol.iterator]()},e.prototype.cast=function(){return this},e.prototype.getIndex=function(){var e=this;return new x.Index(function(){return{values:e.getContent().index}})},e.prototype.withIndex=function(t){var r=this;return j.isFunction(t)?new e(function(){return{values:r.getContent().values,index:r.select(t)}}):(e.checkIterable(t,"newIndex"),new e(function(){return{values:r.getContent().values,index:t}}))},e.prototype.resetIndex=function(){var t=this;return new e(function(){return{values:t.getContent().values}})},e.merge=function(t){var r=new Map,n=Array.from(t).length,i=0;try{for(var u=o(t),a=u.next();!a.done;a=u.next()){var s=a.value;try{for(var c=o(s.toPairs()),l=c.next();!l.done;l=c.next()){var f=l.value,h=f[0].toString();r.has(h)||r.set(h,{index:f[0],values:new Array(n)}),r.get(h).values[i]=f[1]}}catch(e){y={error:e}}finally{try{l&&!l.done&&(m=c.return)&&m.call(c)}finally{if(y)throw y.error}}++i}}catch(e){p={error:e}}finally{try{a&&!a.done&&(d=u.return)&&d.call(u)}finally{if(p)throw p.error}}var p,d,y,m,v=Array.from(r.values()).map(function(e){return[e.index,e.values]});return v.sort(function(e,t){return e[0]===t[0]?0:e[0]>t[0]?1:-1}),new e({pairs:v})},e.prototype.merge=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return e.merge([this].concat(t))},e.prototype.toArray=function(e){var t,r,n=[];try{for(var i=o(this.getContent().values),u=i.next();!u.done;u=i.next()){var a=u.value;e&&e.includeNulls&&void 0!==a?n.push(a):null!=a&&n.push(a)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return n},e.prototype.toPairs=function(){var e,t,r=[];try{for(var n=o(this.getContent().pairs),i=n.next();!i.done;i=n.next()){var u=i.value;void 0!==u[1]&&null!==u[1]&&r.push(u)}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return r},e.prototype.toObject=function(e,t){if(!j.isFunction(e))throw new Error("Expected 'keySelector' parameter to Series.toObject to be a function.");if(!j.isFunction(t))throw new Error("Expected 'valueSelector' parameter to Series.toObject to be a function.");return j.toMap(this,e,t)},e.prototype.select=function(e){if(!j.isFunction(e))throw new Error("Expected 'transformer' parameter to 'Series.select' to be a function.");return this.map(e)},e.prototype.map=function(t){var r=this;if(!j.isFunction(t))throw new Error("Expected 'transformer' parameter to 'Series.map' to be a function.");return new e(function(){var e=r.getContent();return{values:new h.SelectIterable(e.values,t),index:e.index}})},e.prototype.selectMany=function(e){if(!j.isFunction(e))throw new Error("Expected 'transformer' parameter to 'Series.selectMany' to be a function.");return this.flatMap(e)},e.prototype.flatMap=function(t){var r=this;if(!j.isFunction(t))throw new Error("Expected 'transformer' parameter to 'Series.flatMap' to be a function.");return new e(function(){return{pairs:new p.SelectManyIterable(r.getContent().pairs,function(e,r){var n,i,u=[];try{for(var a=o(t(e[1],r)),s=a.next();!s.done;s=a.next()){var c=s.value;u.push([e[0],c])}}catch(e){n={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}return u})}})},e.prototype.window=function(t,r){var n=this;if(!j.isNumber(t))throw new Error("Expected 'period' parameter to 'Series.window' to be a number.");return new e(function(){return{pairs:new D.SeriesWindowIterable(n.getContent().pairs,t,r||N.End)}})},e.prototype.rollingWindow=function(t,r){var n=this;if(!j.isNumber(t))throw new Error("Expected 'period' parameter to 'Series.rollingWindow' to be a number.");return new e(function(){return{pairs:new E.SeriesRollingWindowIterable(n.getContent().pairs,t,r||N.End)}})},e.prototype.variableWindow=function(t){var r=this;if(!j.isFunction(t))throw new Error("Expected 'comparer' parameter to 'Series.variableWindow' to be a function.");return new e(function(){return{values:new F.SeriesVariableWindowIterable(r.getContent().pairs,t)}})},e.prototype.sequentialDistinct=function(e){if(e){if(!j.isFunction(e))throw new Error("Expected 'selector' parameter to 'Series.sequentialDistinct' to be a selector function that determines the value to compare for duplicates.")}else e=function(e){return e};return this.variableWindow(function(t,r){return e(t)===e(r)}).select(function(e){return[e.getIndex().first(),e.first()]}).withIndex(function(e){return e[0]}).select(function(e){return e[1]})},e.prototype.aggregate=function(e,t){if(j.isFunction(e)&&!t)return this.skip(1).aggregate(this.first(),e);if(!j.isFunction(t))throw new Error("Expected 'selector' parameter to aggregate to be a function.");var r,n,i=e;try{for(var u=o(this),a=u.next();!a.done;a=u.next()){i=t(i,a.value)}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=u.return)&&n.call(u)}finally{if(r)throw r.error}}return i},e.prototype.reduce=function(e,t){if(!j.isFunction(e))throw new Error("Expected 'reducer' parameter to `Series.reduce` to be a function.");var r,n,i=t,u=this;void 0===i&&u.any()&&(i=u.first(),u=u.skip(1));try{for(var a=o(u),s=a.next();!s.done;s=a.next()){i=e(i,s.value)}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}return i},e.prototype.amountRange=function(e,t){return this.rollingWindow(e,t).select(function(e){return e.max()-e.min()})},e.prototype.proportionRange=function(e,t){return this.rollingWindow(e,t).select(function(e){return(e.max()-e.min())/e.last()})},e.prototype.percentRange=function(e,t){return this.proportionRange(e,t).select(function(e){return 100*e})},e.prototype.amountChange=function(e,t){return this.rollingWindow(void 0===e?2:e,t).select(function(e){return e.last()-e.first()})},e.prototype.proportionChange=function(e,t){return this.rollingWindow(void 0===e?2:e,t).select(function(e){return(e.last()-e.first())/e.first()})},e.prototype.percentChange=function(e,t){return this.proportionChange(e,t).select(function(e){return 100*e})},e.prototype.proportionRank=function(e){if(void 0===e&&(e=2),!j.isNumber(e))throw new Error("Expected 'period' parameter to 'Series.proportionRank' to be a number that specifies the time period for the ranking.");return this.rollingWindow(e+1).select(function(t){var r=t.last();return t.head(-1).filter(function(e){return e<r}).count()/e})},e.prototype.percentRank=function(e){if(void 0===e&&(e=2),!j.isNumber(e))throw new Error("Expected 'period' parameter to 'Series.percentRank' to be a number that specifies the time period for the ranking.");return this.proportionRank(e).select(function(e){return 100*e})},e.prototype.cumsum=function(){var t=this;return new e(function(){var e=0;return{pairs:t.toPairs().map(function(t){var r=u(t,2),n=r[0],i=r[1];return[n,e+=i]})}})},e.prototype.skip=function(t){var r=this;return new e(function(){return{values:new S.SkipIterable(r.getContent().values,t),index:new S.SkipIterable(r.getContent().index,t),pairs:new S.SkipIterable(r.getContent().pairs,t)}})},e.prototype.skipWhile=function(t){var r=this;if(!j.isFunction(t))throw new Error("Expected 'predicate' parameter to 'Series.skipWhile' function to be a predicate function that returns true/false.");return new e(function(){return{values:new _.SkipWhileIterable(r.getContent().values,t),pairs:new _.SkipWhileIterable(r.getContent().pairs,function(e){return t(e[1])})}})},e.prototype.skipUntil=function(e){if(!j.isFunction(e))throw new Error("Expected 'predicate' parameter to 'Series.skipUntil' function to be a predicate function that returns true/false.");return this.skipWhile(function(t){return!e(t)})},e.prototype.take=function(t){var r=this;if(!j.isNumber(t))throw new Error("Expected 'numRows' parameter to 'Series.take' function to be a number.");return new e(function(){return{index:new d.TakeIterable(r.getContent().index,t),values:new d.TakeIterable(r.getContent().values,t),pairs:new d.TakeIterable(r.getContent().pairs,t)}})},e.prototype.takeWhile=function(t){var r=this;if(!j.isFunction(t))throw new Error("Expected 'predicate' parameter to 'Series.takeWhile' function to be a predicate function that returns true/false.");return new e(function(){return{values:new y.TakeWhileIterable(r.getContent().values,t),pairs:new y.TakeWhileIterable(r.getContent().pairs,function(e){return t(e[1])})}})},e.prototype.takeUntil=function(e){if(!j.isFunction(e))throw new Error("Expected 'predicate' parameter to 'Series.takeUntil' function to be a predicate function that returns true/false.");return this.takeWhile(function(t){return!e(t)})},e.count=function(e){return e.count()},e.prototype.count=function(){var e,t,r=0;try{for(var n=o(this.getContent().values),i=n.next();!i.done;i=n.next()){i.value;++r}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}return r},e.prototype.first=function(){try{for(var e=o(this),t=e.next();!t.done;t=e.next()){return t.value}}catch(e){r={error:e}}finally{try{t&&!t.done&&(n=e.return)&&n.call(e)}finally{if(r)throw r.error}}throw new Error("Series.first: No values in Series.");var r,n},e.prototype.last=function(){var e,t,r=null;try{for(var n=o(this),i=n.next();!i.done;i=n.next()){r=i.value}}catch(t){e={error:t}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}if(null===r)throw new Error("Series.last: No values in Series.");return r},e.prototype.at=function(e){if(!this.none())return this.getRowByIndex(e)},e.prototype.head=function(t){if(!j.isNumber(t))throw new Error("Expected 'numValues' parameter to 'Series.head' function to be a number.");if(0===t)return new e;var r=t<0?this.count()-Math.abs(t):t;return this.take(r)},e.prototype.tail=function(t){if(!j.isNumber(t))throw new Error("Expected 'numValues' parameter to 'Series.tail' function to be a number.");if(0===t)return new e;var r=t>0?this.count()-t:Math.abs(t);return this.skip(r)},e.prototype.where=function(e){if(!j.isFunction(e))throw new Error("Expected 'predicate' parameter to 'Series.where' to be a function.");return this.filter(e)},e.prototype.filter=function(t){var r=this;if(!j.isFunction(t))throw new Error("Expected 'predicate' parameter to 'Series.filter' to be a function.");return new e(function(){r.getContent();return{values:new m.WhereIterable(r.getContent().values,t),pairs:new m.WhereIterable(r.getContent().pairs,function(e){return t(e[1])})}})},e.prototype.forEach=function(e){if(!j.isFunction(e))throw new Error("Expected 'callback' parameter to 'Series.forEach' to be a function.");var t,r,n=0;try{for(var i=o(this),u=i.next();!u.done;u=i.next()){e(u.value,n++)}}catch(e){t={error:e}}finally{try{u&&!u.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return this},e.prototype.all=function(e){if(!j.isFunction(e))throw new Error("Expected 'predicate' parameter to 'Series.all' to be a function.");var t,r,n=0;try{for(var i=o(this),u=i.next();!u.done;u=i.next()){if(!e(u.value))return!1;++n}}catch(e){t={error:e}}finally{try{u&&!u.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return n>0},e.prototype.any=function(e){if(e&&!j.isFunction(e))throw new Error("Expected 'predicate' parameter to 'Series.any' to be a function.");var t,r;if(!e)return!this[Symbol.iterator]().next().done;try{for(var n=o(this),i=n.next();!i.done;i=n.next()){if(e(i.value))return!0}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return!1},e.prototype.none=function(e){if(e&&!j.isFunction(e))throw new Error("Expected 'predicate' parameter to 'Series.none' to be a function.");var t,r;if(!e)return this[Symbol.iterator]().next().done;try{for(var n=o(this),i=n.next();!i.done;i=n.next()){if(e(i.value))return!1}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return!0},e.prototype.startAt=function(t){var r=this;return new e(function(){var e=r.getIndex().getLessThan();return{index:new _.SkipWhileIterable(r.getContent().index,function(r){return e(r,t)}),pairs:new _.SkipWhileIterable(r.getContent().pairs,function(r){return e(r[0],t)})}})},e.prototype.endAt=function(t){var r=this;return new e(function(){var e=r.getIndex().getLessThanOrEqualTo();return{index:new y.TakeWhileIterable(r.getContent().index,function(r){return e(r,t)}),pairs:new y.TakeWhileIterable(r.getContent().pairs,function(r){return e(r[0],t)})}})},e.prototype.before=function(t){var r=this;return new e(function(){var e=r.getIndex().getLessThan();return{index:new y.TakeWhileIterable(r.getContent().index,function(r){return e(r,t)}),pairs:new y.TakeWhileIterable(r.getContent().pairs,function(r){return e(r[0],t)})}})},e.prototype.after=function(t){var r=this;return new e(function(){var e=r.getIndex().getLessThanOrEqualTo();return{index:new _.SkipWhileIterable(r.getContent().index,function(r){return e(r,t)}),pairs:new _.SkipWhileIterable(r.getContent().pairs,function(r){return e(r[0],t)})}})},e.prototype.between=function(e,t){return this.startAt(e).endAt(t)},e.prototype.toString=function(){for(var e=["__index__","__value__"],t=this.toPairs(),r=new B.default,n=0;n<t.length;++n){for(var i=t[n],o=0;o<i.length;++o){var u=i[o];r.cell(e[o],u)}r.newRow()}return r.toString()},e.parseInt=function(e,t){if(null!=e){if(!j.isString(e))throw new Error("Called Series.parseInts, expected all values in the series to be strings, instead found a '"+typeof e+"' at index "+t);if(0!==e.length)return parseInt(e)}},e.prototype.parseInts=function(){return this.select(e.parseInt)},e.parseFloat=function(e,t){if(null!=e){if(!j.isString(e))throw new Error("Called Series.parseFloats, expected all values in the series to be strings, instead found a '"+typeof e+"' at index "+t);if(0!==e.length)return parseFloat(e)}},e.prototype.parseFloats=function(){return this.select(e.parseFloat)},e.parseDate=function(e,t,r){if(null!=e){if(!j.isString(e))throw new Error("Called Series.parseDates, expected all values in the series to be strings, instead found a '"+typeof e+"' at index "+t);if(0!==e.length)return O.default(e,r).toDate()}},e.prototype.parseDates=function(t){if(t&&!j.isString(t))throw new Error("Expected optional 'formatString' parameter to Series.parseDates to be a string (if specified).");return this.select(function(r,n){return e.parseDate(r,n,t)})},e.toString=function(e,t){return void 0===e?void 0:null===e?null:t&&j.isDate(e)?O.default(e).format(t):t&&j.isNumber(e)?P.default(e).format(t):e.toString()},e.prototype.toStrings=function(t){if(t&&!j.isString(t))throw new Error("Expected optional 'formatString' parameter to Series.toStrings to be a string (if specified).");return this.select(function(r){return e.toString(r,t)})},e.prototype.bake=function(){return this.getContent().isBaked?this:new e({values:this.toArray(),pairs:this.toPairs(),baked:!0})},e.prototype.inflate=function(e){var t=this;if(e){if(!j.isFunction(e))throw new Error("Expected 'selector' parameter to Series.inflate to be a selector function.");return new I.DataFrame(function(){var r=t.getContent();return{values:new h.SelectIterable(r.values,e),index:r.index,pairs:new h.SelectIterable(r.pairs,function(t,r){return[t[0],e(t[1],r)]})}})}return new I.DataFrame(function(){var e=t.getContent();return{values:e.values,index:e.index,pairs:e.pairs}})},e.prototype.asNumberSeries=function(){var e=this.filter(function(e){return null!=e});if(e.any(function(e){return"number"!=typeof e}))throw new Error("Expected series to contain only numbers, you should parse this series or filter out non-number values.");return e},e.sum=function(e){return e.sum()},e.prototype.sum=function(){var e=this.asNumberSeries();if(e.none())return 0;var t,r,n=0;try{for(var i=o(e),u=i.next();!u.done;u=i.next()){n+=u.value}}catch(e){t={error:e}}finally{try{u&&!u.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return n},e.average=function(e){return e.average()},e.prototype.average=function(){return this.mean()},e.mean=function(e){return e.mean()},e.prototype.mean=function(){var e=this.asNumberSeries();if(e.none())return 0;var t,r,n=0,i=0;try{for(var u=o(e),a=u.next();!a.done;a=u.next()){var s=a.value;i+=1,n+=s}}catch(e){t={error:e}}finally{try{a&&!a.done&&(r=u.return)&&r.call(u)}finally{if(t)throw t.error}}return 0===i?0:n/i},e.median=function(e){return e.median()},e.prototype.median=function(){var e=this.asNumberSeries(),t=e.count();if(0===t)return 0;var r=e.orderBy(function(e){return e}).toArray();return t%2==0?(r[t/2-1]+r[t/2])/2:r[Math.floor(t/2)]},e.mode=function(e){return e.mode()},e.prototype.mode=function(){var e=this.asNumberSeries();if(!e.none()){var t=new Map;try{for(var r=o(e),n=r.next();!n.done;n=r.next()){var i=n.value;t.has(i)?t.set(i,t.get(i)+1):t.set(i,1)}}catch(e){u={error:e}}finally{try{n&&!n.done&&(a=r.return)&&a.call(r)}finally{if(u)throw u.error}}var u,a,s=Array.from(t.entries());return s.sort(function(e,t){return t[1]-e[1]}),s[0][0]}},e.prototype.sumOfSquares=function(){if(this.none())return[0,1];var e,t,r=this.mean(),n=0,i=this.asNumberSeries(),u=0;try{for(var a=o(i),s=a.next();!s.done;s=a.next()){var c=s.value;u+=1;var l=c-r;n+=l*l}}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=a.return)&&t.call(a)}finally{if(e)throw e.error}}return[n,u]},e.variance=function(e){return e.variance()},e.prototype.variance=function(){if(this.none())return 0;var e=u(this.sumOfSquares(),2);return e[0]/e[1]},e.std=function(e){return e.std()},e.prototype.std=function(){return this.none()?0:Math.sqrt(this.variance())},e.prototype.standardize=function(){if(this.none())return new e;var t=this.mean(),r=this.std();if(0===r)throw new Error("Can't standardize a series that has no variation.");return this.asNumberSeries().map(function(e){return(e-t)/r})},e.sampleVariance=function(e){return e.sampleVariance()},e.prototype.sampleVariance=function(){if(this.none())return 0;var e=u(this.sumOfSquares(),2);return e[0]/(e[1]-1)},e.sampleStd=function(e){return e.sampleStd()},e.prototype.sampleStd=function(){return this.none()?0:Math.sqrt(this.sampleVariance())},e.prototype.sampleStandardize=function(){if(this.none())return new e;var t=this.mean(),r=this.sampleStd();if(0===r)throw new Error("Can't standardize a series that has no variation.");return this.asNumberSeries().map(function(e){return(e-t)/r})},e.min=function(e){return e.min()},e.prototype.min=function(){var e,t,r;try{for(var n=o(this.asNumberSeries()),i=n.next();!i.done;i=n.next()){var u=i.value;e=void 0===e?u:Math.min(e,u)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return void 0===e?0:e},e.max=function(e){return e.max()},e.prototype.max=function(){var e,t,r;try{for(var n=o(this.asNumberSeries()),i=n.next();!i.done;i=n.next()){var u=i.value;e=void 0===e?u:Math.max(e,u)}}catch(e){t={error:e}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(t)throw t.error}}return void 0===e?0:e},e.range=function(e){return e.range()},e.prototype.range=function(){return this.max()-this.min()},e.prototype.invert=function(){return this.asNumberSeries().select(function(e){return-e})},e.prototype.counter=function(e){return this.groupSequentialBy(e).selectMany(function(t,r){return e(t.first())?M.range(1,t.count()).withIndex(t.getIndex()).toPairs():M.replicate(0,t.count()).withIndex(t.getIndex()).toPairs()}).withIndex(function(e){return e[0]}).select(function(e){return e[1]})},e.prototype.reverse=function(){var t=this;return new e(function(){return{values:new g.ReverseIterable(t.getContent().values),index:new g.ReverseIterable(t.getContent().index),pairs:new g.ReverseIterable(t.getContent().pairs)}})},e.prototype.distinct=function(t){var r=this;return new e(function(){return{values:new b.DistinctIterable(r.getContent().values,t),pairs:new b.DistinctIterable(r.getContent().pairs,function(e){return t&&t(e[1])||e[1]})}})},e.prototype.groupBy=function(t){var r=this;if(!j.isFunction(t))throw new Error("Expected 'selector' parameter to 'Series.groupBy' to be a selector function that determines the value to group the series by.");return new e(function(){var n,i,u=[],a={},s=0;try{for(var c=o(r.getContent().pairs),l=c.next();!l.done;l=c.next()){var f=l.value,h=t(f[1],s);++s;var p=a[h];if(p)p.push(f);else{var d=[];d.push(f),u.push(d),a[h]=d}}}catch(e){n={error:e}}finally{try{l&&!l.done&&(i=c.return)&&i.call(c)}finally{if(n)throw n.error}}return{values:u.map(function(t){return new e({pairs:t})})}})},e.prototype.groupSequentialBy=function(e){if(e){if(!j.isFunction(e))throw new Error("Expected 'selector' parameter to 'Series.groupSequentialBy' to be a selector function that determines the value to group the series by.")}else e=function(e){return e};return this.variableWindow(function(t,r){return e(t)===e(r)})},e.concat=function(t){if(!j.isArray(t))throw new Error("Expected 'series' parameter to 'Series.concat' to be an array of series.");return new e(function(){var e=t.map(function(e){return e.getContent()});return{values:new v.ConcatIterable(e.map(function(e){return e.values})),pairs:new v.ConcatIterable(e.map(function(e){return e.pairs}))}})},e.prototype.concat=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n,i,u,a,s=[this];try{for(var c=o(t),l=c.next();!l.done;l=c.next()){var f=l.value;if(j.isArray(f))try{for(var h=o(f),p=h.next();!p.done;p=h.next()){var d=p.value;s.push(d)}}catch(e){u={error:e}}finally{try{p&&!p.done&&(a=h.return)&&a.call(h)}finally{if(u)throw u.error}}else s.push(f)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(i=c.return)&&i.call(c)}finally{if(n)throw n.error}}return e.concat(s)},e.zip=function(t,r){var n=Array.from(t);if(0===n.length)return new e;var i=n[0];return i.none()?new e:new e(function(){var e=n;return{index:i.getContent().index,values:new w.ZipIterable(e.map(function(e){return e.getContent().values}),r)}})},e.prototype.zip=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var n=t[t.length-1],i=[this].concat(t.slice(0,t.length-1));return e.zip(i,function(e){return n.apply(void 0,a(e))})},e.prototype.orderBy=function(e){var t=this.getContent();return new L({values:t.values,pairs:t.pairs,selector:e,direction:C.Direction.Ascending,parent:null})},e.prototype.orderByDescending=function(e){var t=this.getContent();return new L({values:t.values,pairs:t.pairs,selector:e,direction:C.Direction.Descending,parent:null})},e.prototype.union=function(e,t){if(t&&!j.isFunction(t))throw new Error("Expected optional 'selector' parameter to 'Series.union' to be a selector function.");return this.concat(e).distinct(t)},e.prototype.intersection=function(e,t,r){if(t){if(!j.isFunction(t))throw new Error("Expected optional 'outerSelector' parameter to 'Series.intersection' to be a function.")}else t=function(e){return e};if(r){if(!j.isFunction(r))throw new Error("Expected optional 'innerSelector' parameter to 'Series.intersection' to be a function.")}else r=function(e){return e};return this.filter(function(n){var i=t(n);return e.filter(function(e){return i===r(e)}).any()})},e.prototype.except=function(e,t,r){if(t){if(!j.isFunction(t))throw new Error("Expected optional 'outerSelector' parameter to 'Series.except' to be a function.")}else t=function(e){return e};if(r){if(!j.isFunction(r))throw new Error("Expected optional 'innerSelector' parameter to 'Series.except' to be a function.")}else r=function(e){return e};return this.filter(function(n){var i=t(n);return e.filter(function(e){return i===r(e)}).none()})},e.prototype.join=function(t,r,n,i){if(!j.isFunction(r))throw new Error("Expected 'outerKeySelector' parameter of 'Series.join' to be a selector function.");if(!j.isFunction(n))throw new Error("Expected 'innerKeySelector' parameter of 'Series.join' to be a selector function.");if(!j.isFunction(i))throw new Error("Expected 'resultSelector' parameter of 'Series.join' to be a selector function.");var u=this;return new e(function(){var e,a,s,c,l=t.groupBy(n).toObject(function(e){return n(e.first())},function(e){return e}),f=(u.getContent(),[]);try{for(var h=o(u),p=h.next();!p.done;p=h.next()){var d=p.value,y=l[r(d)];if(y)try{for(var m=o(y),v=m.next();!v.done;v=m.next()){var D=v.value;f.push(i(d,D))}}catch(e){s={error:e}}finally{try{v&&!v.done&&(c=m.return)&&c.call(m)}finally{if(s)throw s.error}}}}catch(t){e={error:t}}finally{try{p&&!p.done&&(a=h.return)&&a.call(h)}finally{if(e)throw e.error}}return{values:f}})},e.prototype.joinOuter=function(e,t,r,n){if(!j.isFunction(t))throw new Error("Expected 'outerKeySelector' parameter of 'Series.joinOuter' to be a selector function.");if(!j.isFunction(r))throw new Error("Expected 'innerKeySelector' parameter of 'Series.joinOuter' to be a selector function.");if(!j.isFunction(n))throw new Error("Expected 'resultSelector' parameter of 'Series.joinOuter' to be a selector function.");var i=this.except(e,t,r).select(function(e){return n(e,null)}).resetIndex(),o=e.except(this,r,t).select(function(e){return n(null,e)}).resetIndex(),u=this.join(e,t,r,n);return i.concat(u).concat(o).resetIndex()},e.prototype.joinOuterLeft=function(e,t,r,n){if(!j.isFunction(t))throw new Error("Expected 'outerKeySelector' parameter of 'Series.joinOuterLeft' to be a selector function.");if(!j.isFunction(r))throw new Error("Expected 'innerKeySelector' parameter of 'Series.joinOuterLeft' to be a selector function.");if(!j.isFunction(n))throw new Error("Expected 'resultSelector' parameter of 'Series.joinOuterLeft' to be a selector function.");var i=this.except(e,t,r).select(function(e){return n(e,null)}).resetIndex(),o=this.join(e,t,r,n);return i.concat(o).resetIndex()},e.prototype.joinOuterRight=function(e,t,r,n){if(!j.isFunction(t))throw new Error("Expected 'outerKeySelector' parameter of 'Series.joinOuterRight' to be a selector function.");if(!j.isFunction(r))throw new Error("Expected 'innerKeySelector' parameter of 'Series.joinOuterRight' to be a selector function.");if(!j.isFunction(n))throw new Error("Expected 'resultSelector' parameter of 'Series.joinOuterRight' to be a selector function.");var i=e.except(this,r,t).select(function(e){return n(null,e)}).resetIndex();return this.join(e,t,r,n).concat(i).resetIndex()},e.prototype.truncateStrings=function(e){if(!j.isNumber(e))throw new Error("Expected 'maxLength' parameter to 'Series.truncateStrings' to be a number.");return this.select(function(t){return j.isString(t)&&t.length>e?t.substring(0,e):t})},e.prototype.round=function(e){if(void 0!==e){if(!j.isNumber(e))throw new Error("Expected 'numDecimalPlaces' parameter to 'Series.round' to be a number.")}else e=2;return this.select(function(t){return j.isNumber(t)?parseFloat(t.toFixed(e)):t})},e.prototype.insertPair=function(t){if(!j.isArray(t))throw new Error("Expected 'pair' parameter to 'Series.insertPair' to be an array.");if(2!==t.length)throw new Error("Expected 'pair' parameter to 'Series.insertPair' to be an array with two elements. The first element is the index, the second is the value.");return new e({pairs:[t]}).concat(this)},e.prototype.appendPair=function(t){if(!j.isArray(t))throw new Error("Expected 'pair' parameter to 'Series.appendPair' to be an array.");if(2!==t.length)throw new Error("Expected 'pair' parameter to 'Series.appendPair' to be an array with two elements. The first element is the index, the second is the value.");return this.concat(new e({pairs:[t]}))},e.prototype.remove=function(t){var r=this;return new e(function(){var e=r.getContent();return{pairs:new m.WhereIterable(e.pairs,function(e){return e[0]!==t})}})},e.prototype.fillGaps=function(e,t){if(!j.isFunction(e))throw new Error("Expected 'comparer' parameter to 'Series.fillGaps' to be a comparer function that compares two values and returns a boolean.");if(!j.isFunction(t))throw new Error("Expected 'generator' parameter to 'Series.fillGaps' to be a generator function that takes two values and returns an array of generated pairs to span the gap.");return this.rollingWindow(2).selectMany(function(r){var n=r.toPairs(),i=n[0],o=n[1];if(!e(i,o))return[i];var u=t(i,o);if(!j.isArray(u))throw new Error("Expected return from 'generator' parameter to 'Series.fillGaps' to be an array of pairs, instead got a "+typeof u);return[i].concat(u)}).withIndex(function(e){return e[0]}).select(function(e){return e[1]}).concat(this.tail(1))},e.prototype.defaultIfEmpty=function(t){if(this.none()){if(t instanceof e)return t;if(j.isArray(t))return new e(t);throw new Error("Expected 'defaultSequence' parameter to 'Series.defaultIfEmpty' to be an array or a series.")}return this},e.prototype.detectTypes=function(){var e=this;return new I.DataFrame(function(){var t=e.count(),r=e.select(function(e){var t=typeof e;return"object"===t&&j.isDate(e)&&(t="date"),t}).aggregate({},function(e,t){var r=e[t];return r||(r={count:0},e[t]=r),++r.count,e});return{columnNames:["Type","Frequency"],rows:Object.keys(r).map(function(e){return[e,r[e].count/t*100]})}})},e.prototype.detectValues=function(){var e=this;return new I.DataFrame(function(){var t=e.count(),r=e.aggregate(new Map,function(e,t){var r=e.get(t);return r||(r={count:0,value:t},e.set(t,r)),++r.count,e});return{columnNames:["Value","Frequency"],rows:Array.from(r.keys()).map(function(e){var n=r.get(e);return[n.value,n.count/t*100]})}})},e.prototype.bucket=function(e){if(console.warn("Series.bucket is deprecated and will be removed in the future."),!j.isNumber(e))throw new Error("Expected 'numBuckets' parameter to 'Series.bucket' to be a number.");if(this.none())return new I.DataFrame;var t=this.min(),r=(this.max()-t)/(e-1);return this.select(function(e){var n=Math.floor((e-t)/r),i=n*r+t;return{Value:e,Bucket:n,Min:i,Mid:i+.5*r,Max:i+r}}).inflate()},e.prototype.frequency=function(e){var t=this;return this.none()?new I.DataFrame:new I.DataFrame(function(){var r,n,i=t,u=e&&e.captureValues||!1,a=Number.MAX_VALUE,s=Number.MIN_VALUE,c=0;try{for(var l=o(i),f=l.next();!f.done;f=l.next()){var h=f.value;a=Math.min(h,a),s=Math.max(h,s),c+=1}}catch(e){C={error:e}}finally{try{f&&!f.done&&(x=l.return)&&x.call(l)}finally{if(C)throw C.error}}r=e&&void 0!==e.lower?e.lower:a,n=e&&void 0!==e.upper?e.upper:s;var p,d=e&&e.interval,y=n-r;c<(p=void 0!==d?Math.ceil(y/d):10)&&(p=c),void 0===d&&(d=y/(p-1));for(var m=new Array(p),v=0;v<p;++v){var D=r+v*d;m[v]={lower:D,upper:D+d,count:0,proportion:0,cumulative:0},u&&(m[v].values=[])}var g={upper:r,count:0,proportion:0,cumulative:0};u&&(g.values=[]);var w={lower:n,count:0,proportion:0,cumulative:0};u&&(w.values=[]);try{for(var b=o(i),E=b.next();!E.done;E=b.next()){h=E.value;var F=void 0;if(h<r)F=g;else if(h>n)F=w;else{F=m[v=Math.floor((h-r)/d)]}F.count+=1,u&&F.values.push(h)}}catch(e){A={error:e}}finally{try{E&&!E.done&&(S=b.return)&&S.call(b)}finally{if(A)throw A.error}}var C,x,A,S,_,B,I=0;g.count>0&&m.unshift(g),w.count>0&&m.push(w);try{for(var O=o(m),k=O.next();!k.done;k=O.next()){(F=k.value).proportion=F.count/c,I+=F.proportion,F.cumulative=I}}catch(e){_={error:e}}finally{try{k&&!k.done&&(B=O.return)&&B.call(O)}finally{if(_)throw _.error}}return{values:m}})},e.prototype.getTypeCode=function(){return"series"},e.defaultCountIterable=new l.CountIterable,e.defaultEmptyIterable=new c.EmptyIterable,e}();t.Series=R;var L=function(e){function t(r){for(var n,i,u=this,a=[],s=[],c=0,l=r.parent,f=[];null!==l;)f.push(l),l=l.config.parent;f.reverse();try{for(var h=o(f),p=h.next();!p.done;p=h.next()){var d=p.value.config;a.push(t.makeSortSpec(c,d.selector,d.direction)),s.push(t.makeSortSpec(c,t.makePairsSelector(d.selector),d.direction)),++c}}catch(e){n={error:e}}finally{try{p&&!p.done&&(i=h.return)&&i.call(h)}finally{if(n)throw n.error}}return a.push(t.makeSortSpec(c,r.selector,r.direction)),s.push(t.makeSortSpec(c,t.makePairsSelector(r.selector),r.direction)),(u=e.call(this,{values:new C.OrderedIterable(r.values,a),pairs:new C.OrderedIterable(r.pairs,s)})||this).config=r,u}return i(t,e),t.makeSortSpec=function(e,t,r){return{sortLevel:e,selector:t,direction:r}},t.makePairsSelector=function(e){return function(t,r){return e(t[1],r)}},t.prototype.thenBy=function(e){return new t({values:this.config.values,pairs:this.config.pairs,selector:e,direction:C.Direction.Ascending,parent:this})},t.prototype.thenByDescending=function(e){return new t({values:this.config.values,pairs:this.config.pairs,selector:e,direction:C.Direction.Descending,parent:this})},t}(R)},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__values||function(e){var t="function"==typeof Symbol&&e[Symbol.iterator],r=0;return t?t.call(e):{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}}},u=this&&this.__read||function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),u=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)u.push(n.value)}catch(e){i={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return u},a=this&&this.__spread||function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(u(arguments[t]));return e},s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});var c=r(7),l=r(8),f=r(9),h=r(10),p=r(11),d=r(12),y=r(13),m=r(14),v=r(15),D=r(57),g=r(16),w=r(17),b=r(59),E=r(18),F=r(61),C=r(63),x=r(19),A=r(5),S=r(20),_=r(21),B=r(22),I=r(65),O=r(67),k=r(69),N=s(r(23)),j=s(r(3)),M=r(0),P=r(71),T=r(4),R=s(r(24)),L=s(r(25)),W=r(26),$=function(){function e(t){if(this.configFn=null,this.content=null,this.indexedContent=null,t){var r=t;if(void 0!==r.getTypeCode){var n=r.getTypeCode();if("dataframe"===n||"series"===n)return void(void 0!==r.content?this.content=r.content:this.configFn=r.configFn)}T.isFunction(t)?this.configFn=t:e.isIterator(t)?this.content=e.initFromIterator(t):e.isIterable(t)?this.content=e.initFromIterable(t):this.content=e.initFromConfig(t)}else this.content=e.initEmpty()}return e.initFromIterator=function(t){return e.initFromIterable(new W.CachedIteratorIterable(t))},e.initFromIterable=function(t){var r=t[Symbol.iterator]().next(),n=r.done?[]:Object.keys(r.value);return{index:e.defaultCountIterable,values:t,pairs:new f.MultiIterable([e.defaultCountIterable,t]),isBaked:!0,columnNames:n,isCaseSensitive:!1}},e.initEmpty=function(){return{index:e.defaultEmptyIterable,values:e.defaultEmptyIterable,pairs:e.defaultEmptyIterable,isBaked:!0,columnNames:[],isCaseSensitive:!1}},e.initColumnNames=function(e,t){var r=[],n={},i=Array.from(e).map(function(e){return e.toString()});try{for(var u=o(i),a=u.next();!a.done;a=u.next()){var s=a.value;void 0===n[m=void 0!==t&&t?s:s.toLowerCase()]?n[m]=1:n[m]+=1}}catch(e){c={error:e}}finally{try{a&&!a.done&&(l=u.return)&&l.call(u)}finally{if(c)throw c.error}}var c,l,f,h,p={};try{for(var d=o(i),y=d.next();!y.done;y=d.next()){var m;s=y.value;if(n[m=void 0!==t&&t?s:s.toLowerCase()]>1){var v=1;void 0!==p[m]&&(v=p[m]),r.push(s+"."+v),p[m]=v+1}else r.push(s)}}catch(e){f={error:e}}finally{try{y&&!y.done&&(h=d.return)&&h.call(d)}finally{if(f)throw f.error}}return r},e.isIterator=function(e){return T.isObject(e)&&T.isFunction(e.next)},e.isIterable=function(e){return T.isArray(e)||T.isObject(e)&&T.isFunction(e[Symbol.iterator])},e.checkIterable=function(t,r){if(!e.isIterable(t))throw new Error("Expected '"+r+"' field of DataFrame config object to be an array of values or an iterable of values.")},e.initFromConfig=function(t){var r,n,i,u,a,s,c=!1;if(t.pairs&&(e.isIterator(t.pairs)?i=new W.CachedIteratorIterable(t.pairs):(e.checkIterable(t.pairs,"pairs"),i=t.pairs)),t.columns){var p=t.columns;if(e.isIterator(p)&&(p=new W.CachedIteratorIterable(p)),e.isIterable(p)){var d=p;u=Array.from(d).map(function(e){return e.name}),p=T.toMap(d,function(e){return e.name},function(e){return e.series})}else{if(!T.isObject(p))throw new Error("Expected 'columns' member of 'config' parameter to DataFrame constructor to be an object with fields that define columns.");u=Object.keys(p)}var y=[];try{for(var m=o(u),v=m.next();!v.done;v=m.next()){var D=v.value,g=p[D];e.isIterator(g)?g=new W.CachedIteratorIterable(g):e.checkIterable(g,D),y.push(g)}}catch(e){a={error:e}}finally{try{v&&!v.done&&(s=m.return)&&s.call(m)}finally{if(a)throw a.error}}n=new b.CsvRowsIterable(u,new f.MultiIterable(y))}else if(t.columnNames&&(u=e.isIterator(t.columnNames)?new W.CachedIteratorIterable(t.columnNames):t.columnNames,u=this.initColumnNames(u,t.caseSensitive)),t.rows){t.columnNames||(u=new h.SelectIterable(new l.CountIterable,function(e){return"Column."+e.toString()}));var w=void 0;e.isIterator(t.rows)?w=new W.CachedIteratorIterable(t.rows):(e.checkIterable(t.rows,"rows"),w=t.rows),n=new b.CsvRowsIterable(u,w)}else t.values?(e.isIterator(t.values)?n=new W.CachedIteratorIterable(t.values):(e.checkIterable(t.values,"values"),n=t.values),t.columnNames||(u=new P.ColumnNamesIterable(n,t.considerAllRows||!1))):i?(n=new S.ExtractElementIterable(i,1),t.columnNames||(u=new P.ColumnNamesIterable(n,t.considerAllRows||!1))):(n=e.defaultEmptyIterable,t.columnNames||(u=e.defaultEmptyIterable));return t.index?e.isIterator(t.index)?r=new W.CachedIteratorIterable(t.index):(e.checkIterable(t.index,"index"),r=t.index):r=i?new S.ExtractElementIterable(i,0):e.defaultCountIterable,i||(i=new f.MultiIterable([r,n])),void 0!==t.baked&&(c=t.baked),{index:r,values:n,pairs:i,isBaked:c,columnNames:u,isCaseSensitive:t.caseSensitive||!1}},e.prototype.lazyInit=function(){null===this.content&&null!==this.configFn&&(this.content=e.initFromConfig(this.configFn()))},e.prototype.getContent=function(){return this.lazyInit(),this.content},e.prototype.getRowByIndex=function(e){if(!this.indexedContent){this.indexedContent=new Map;try{for(var t=o(this.getContent().pairs),r=t.next();!r.done;r=t.next()){var n=r.value;this.indexedContent.set(n[0],n[1])}}catch(e){i={error:e}}finally{try{r&&!r.done&&(u=t.return)&&u.call(t)}finally{if(i)throw i.error}}}return this.indexedContent.get(e);var i,u},e.prototype[Symbol.iterator]=function(){return this.getContent().values[Symbol.iterator]()},e.prototype.getColumnNames=function(){return Array.from(this.getContent().columnNames)},e.prototype.getColumns=function(){var e=this;return new M.Series(function(){return{values:e.getColumnNames().map(function(t){var r=e.getSeries(t).skipWhile(function(e){return null==e}),n=r.any()?r.first():void 0;return{name:t,type:T.determineType(n),series:r}})}})},e.prototype.isCaseSensitive=function(){return this.getContent().isCaseSensitive},e.prototype.cast=function(){return this},e.prototype.getIndex=function(){var e=this;return new A.Index(function(){return{values:e.getContent().index}})},e.prototype.setIndex=function(e){if(!T.isString(e))throw new Error("Expected 'columnName' parameter to 'DataFrame.setIndex' to be a string that specifies the name of the column to set as the index for the dataframe.");return this.withIndex(this.getSeries(e))},e.prototype.withIndex=function(t){var r=this;return T.isFunction(t)?new e(function(){var e=r.getContent();return{columnNames:e.columnNames,values:e.values,index:r.deflate(t)}}):(e.checkIterable(t,"newIndex"),new e(function(){var e=r.getContent();return{columnNames:e.columnNames,values:e.values,index:t}}))},e.prototype.resetIndex=function(){var t=this;return new e(function(){var e=t.getContent();return{columnNames:e.columnNames,values:e.values}})},e.prototype.getSeries=function(e){var t=this;if(!T.isString(e))throw new Error("Expected 'columnName' parameter to 'DataFrame.getSeries' function to be a string that specifies the name of the column to retreive.");return new M.Series(function(){return{values:new h.SelectIterable(t.getContent().values,function(t){return t[e]}),index:t.getContent().index}})},e.prototype.hasSeries=function(e){var t,r,n=e.toLowerCase();try{for(var i=o(this.getColumnNames()),u=i.next();!u.done;u=i.next()){if(u.value.toLowerCase()===n)return!0}}catch(e){t={error:e}}finally{try{u&&!u.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return!1},e.prototype.expectSeries=function(e){if(!this.hasSeries(e))throw new Error("Expected dataframe to contain series with column name: '"+e+"'.");return this.getSeries(e)},e.prototype.withSeries=function(t,r){var n=this;if(T.isObject(t)){if(!T.isUndefined(r))throw new Error("Expected 'series' parameter to 'DataFrame.withSeries' to not be set when 'columnNameOrSpec is an object.")}else{if(!T.isString(t))throw new Error("Expected 'columnNameOrSpec' parameter to 'DataFrame.withSeries' function to be a string that specifies the column to set or replace.");if(!T.isFunction(r)&&!T.isObject(r))throw new Error("Expected 'series' parameter to 'DataFrame.withSeries' to be a Series object or a function that takes a dataframe and produces a Series.")}if(T.isObject(t)){var i=t,u=Object.keys(i),a=this;try{for(var s=o(u),c=s.next();!c.done;c=s.next()){var l=c.value;a=a.withSeries(l,i[l])}}catch(e){f={error:e}}finally{try{c&&!c.done&&(p=s.return)&&p.call(s)}finally{if(f)throw f.error}}return a.cast()}var f,p,d=t;if(this.none()){return(T.isFunction(r)?r(this):r).inflate(function(e){var t={};return t[d]=e,t}).cast()}return new e(function(){var e;e=T.isFunction(r)?r(n):r;var t=T.toMap2(e.toPairs(),function(e){return e[0]},function(e){return e[1]});return{columnNames:T.makeDistinct(n.getColumnNames().concat([d])),index:n.getContent().index,pairs:new h.SelectIterable(n.getContent().pairs,function(e){var r=e[0],n=e[1],i=Object.assign({},n);return i[d]=t.get(r),[r,i]})}})},e.merge=function(t){var r=!1,n=new Map;try{for(var i=o(t),u=i.next();!u.done;u=i.next()){var a=u.value;a.isCaseSensitive()&&(r=!0);try{for(var s=o(a.toPairs()),c=s.next();!c.done;c=s.next()){var l=c.value,f=l[0].toString();if(n.has(f)){var h=n.get(f),p={index:l[0],value:Object.assign({},h.value,l[1])};n.set(f,p)}else n.set(f,{index:l[0],value:l[1]})}}catch(e){m={error:e}}finally{try{c&&!c.done&&(v=s.return)&&v.call(s)}finally{if(m)throw m.error}}}}catch(e){d={error:e}}finally{try{u&&!u.done&&(y=i.return)&&y.call(i)}finally{if(d)throw d.error}}var d,y,m,v,D=Array.from(t).map(function(e){return e.getColumnNames()}).reduce(function(e,t){return e.concat(t)},[]),g=T.makeDistinct(D),w=Array.from(n.values()).map(function(e){return[e.index,e.value]});return w.sort(function(e,t){return e[0]===t[0]?0:e[0]>t[0]?1:-1}),new e({columnNames:g,pairs:w,caseSensitive:r})},e.prototype.merge=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return e.merge([this].concat(t))},e.prototype.ensureSeries=function(e,t){if(T.isObject(e)){if(!T.isUndefined(t))throw new Error("Expected 'series' parameter to 'DataFrame.ensureSeries' to not be set when 'columnNameOrSpec is an object.")}else{if(!T.isString(e))throw new Error("Expected 'columnNameOrSpec' parameter to 'DataFrame.ensureSeries' function to be a string that specifies the column to set or replace.");if(!T.isFunction(t)&&!T.isObject(t))throw new Error("Expected 'series' parameter to 'DataFrame.ensureSeries' to be a Series object or a function that takes a dataframe and produces a Series.")}if(T.isObject(e)){var r=e,n=Object.keys(e),i=this;try{for(var u=o(n),a=u.next();!a.done;a=u.next()){var s=a.value;i=i.ensureSeries(s,r[s])}}catch(e){c={error:e}}finally{try{a&&!a.done&&(l=u.return)&&l.call(u)}finally{if(c)throw c.error}}return i}var c,l,f=e;return this.hasSeries(f)?this:this.withSeries(f,t)},e.prototype.subset=function(t){var r=this;if(!T.isArray(t))throw new Error("Expected 'columnNames' parameter to 'DataFrame.subset' to be an array of column names to keep.");return new e(function(){var e=r.getContent();return{columnNames:t,index:e.index,values:new h.SelectIterable(e.values,function(e){var r,n,i={};try{for(var u=o(t),a=u.next();!a.done;a=u.next()){var s=a.value;i[s]=e[s]}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=u.return)&&n.call(u)}finally{if(r)throw r.error}}return i}),pairs:new h.SelectIterable(e.pairs,function(e){var r,n,i={},u=e[1];try{for(var a=o(t),s=a.next();!s.done;s=a.next()){var c=s.value;i[c]=u[c]}}catch(e){r={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}return[e[0],i]})}})},e.prototype.dropSeries=function(t){var r=this;if(!T.isArray(t)){if(!T.isString(t))throw new Error("'DataFrame.dropSeries' expected either a string or an array or strings.");t=[t]}return new e(function(){var e,n,i=r.getContent(),u=[];try{for(var a=o(i.columnNames),s=a.next();!s.done;s=a.next()){var c=s.value;-1===t.indexOf(c)&&u.push(c)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}return{columnNames:u,index:i.index,values:new h.SelectIterable(i.values,function(e){var r,n,i=Object.assign({},e);try{for(var u=o(t),a=u.next();!a.done;a=u.next()){delete i[a.value]}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=u.return)&&n.call(u)}finally{if(r)throw r.error}}return i}),pairs:new h.SelectIterable(i.pairs,function(e){var r,n,i=Object.assign({},e[1]);try{for(var u=o(t),a=u.next();!a.done;a=u.next()){delete i[a.value]}}catch(e){r={error:e}}finally{try{a&&!a.done&&(n=u.return)&&n.call(u)}finally{if(r)throw r.error}}return[e[0],i]})}})},e.prototype.reorderSeries=function(t){var r,n,i=this;if(!T.isArray(t))throw new Error("Expected parameter 'columnNames' to 'DataFrame.reorderSeries' to be an array with column names.");try{for(var u=o(t),a=u.next();