jsdataframe
Advanced tools
+10
| ## 0.1.1 | ||
| * Add `jd.version` property | ||
| * Move polyfills to top of script | ||
| * Fix printing bug involving old 'rngCat' code | ||
| ## 0.1.0 | ||
| * Initial version | ||
@@ -1,3 +0,3 @@ | ||
| !function(t,e){"function"==typeof define&&define.amd?define(["exports"],e):e("object"==typeof exports&&"string"!=typeof exports.nodeName?exports:t.jsdataframe={})}(this,function(t){"use strict";function e(t){return String.fromCharCode(t)}function r(t,e,r){var n,i=r.size(),o=t.length-e,u=ot(i);for(n=0;i>n;n++)u[n]=ot(o);for(var s=0;o>s;s++){var a=t[s+e];if(a.length!==i)throw new Error("all row arrays must be of the same size");for(n=0;i>n;n++)u[n][s]=a[n]}return mt(u,r)}function n(t){return 0!==t&&Math.abs(t)<pe}function i(t){return Math.abs(t)>de}function o(t){var e=t.nChar().max(),r=Pt.rep(" ",e).strJoin("");return t.map(function(t){return(r+t).slice(-r.length)})}function u(t,e){var r=Pt.seq(t)._toTruncatedPrintVector(e);return r.map(function(t){return t===ye?t:t+ge})}function s(t){if(Ut(t))return"undefined";if(null===t)return"null";if(Number.isNaN(t))return"NaN";var e=xt(t),r=e.split("\n",2);return r.length>1&&(e=r[0]+"..."),e.length>he&&(e=e.slice(0,he-3)+"..."),e}function a(t,e,r){if("number"!=typeof t||Number.isNaN(t))throw new Error('"'+r+'" must be a number');if(e>t)throw new Error('"'+r+'" too small')}function l(t){var e=t.toString().split(".");return e.length>1?e[1].length:0}function c(t){return!it(t)}function h(t,e,r,n){return it(e)?n:e?t:r}function f(t,e){return 0===Ot(t,e)}function v(t,e){return Number.isNaN(t)&&Number.isNaN(e)||t===e}function p(t,e){return Ot(t,e)<0}function d(t,e){return Ot(t,e)>0}function m(t,e){return Number.isNaN(t)&&Number.isNaN(e)||Math.abs(t-e)<=1e-7}function y(t,e){return Ot(e,t)<0?e:t}function g(t,e){return Ot(e,t)>0?e:t}function b(t,e,r){var n=it(e),i=it(r);if(!n&&!i&&e>r)throw new Error("invalid range: lower ("+e+") > upper ("+r+")");return it(t)?t:!n&&e>t?e:!i&&t>r?r:t}function w(t,e){return t+e}function _(t,e){return t-e}function x(t,e){return t*e}function N(t,e){return t/e}function E(t,e){return t%e}function O(t,e){return t.n++,t.sum+=e,t}function j(t,e){t.n++;var r=e-t.mean;return t.mean+=r/t.n,t.M2+=r*(e-t.mean),t}function A(t,e){return t===!1||e===!1?!1:null===t||null===e?null:!0}function C(t,e){return t===!0||e===!0?!0:null===t||null===e?null:!1}function M(t){return!t}function z(t,e){return null===t||null===e?null:t!==e}function S(t,e){return+t+ +e}function k(t){return t.length}function I(t,e,r){return null===t?null:t.includes(e,r)}function R(t,e,r){return null===t?null:t.startsWith(e,r)}function T(t,e,r){return null===t?null:t.endsWith(e,r)}function q(t,e,r){return null===t?NaN:t.indexOf(e,r)}function L(t,e,r){return null===t?NaN:t.lastIndexOf(e,r)}function V(t,e){return null===t?NaN:t.search(e)}function D(t,e){return null===e||null===t?null:e.test(t)}function B(t){return null===t?null:t.toLowerCase()}function W(t){return null===t?null:t.toUpperCase()}function F(t){return function(){var e=t.apply(null,arguments);if(null===e)return e;var r=this[e];return Ut(r)&&(this[e]=e,r=e),r}}function K(t,e,r,n,i,o,u,s){var a,l,c=s?o:i,h=0;for(l=e.nCol(),a=0;l>a;a++)t[h].push(e._cols[a].values[c]),h++;for(l=r.nCol(),a=0;l>a;a++){var f=null===i?null:r._cols[a].values[i];t[h].push(f),h++}for(l=n.nCol(),a=0;l>a;a++){var v=null===o?null:n._cols[a].values[o];t[h].push(v),h++}h<t.length&&t[h].push(u)}function U(t,e,r){var n,i;if(Ut(r)||Ut(r.by)&&Ut(r.leftBy)&&Ut(r.rightBy)){var o=t.names().s(t.names().isIn(e.names()));if(o.nUnique()!==o.size())throw new Error("duplicate names found for key columns");n=Y(o,t._names,t._dtypesVector()),i=Y(o,e._names,e._dtypesVector())}else if(Ut(r.by)){if(Ut(r.leftBy)||Ut(r.rightBy))throw new Error("must specify both opts.leftBy and "+"opts.rightBy together");n=Y(r.leftBy,t._names,t._dtypesVector()),i=Y(r.rightBy,e._names,e._dtypesVector())}else{if(!Ut(r.leftBy)||!Ut(r.rightBy))throw new Error("cannot define opts.by, opts.leftBy, and "+"opts.rightBy all together");if(null!==r.by&&"object"==typeof r.by&&r.by.type!==Yt.type){var u=Object.keys(r.by),s=u.map(function(t){return r.by[t]});n=Y(u,t._names,t._dtypesVector()),i=Y(s,e._names,e._dtypesVector())}else{var a=Vt(r.by,"string");if(n=Y(a,t._names,t._dtypesVector()),i=Y(a,e._names,e._dtypesVector()),a.size()!==n.size())throw new Error("duplicate names found for key columns")}}if(dt(n),dt(i),n.size()!==i.size())throw new Error("must select the same number of key columns on the "+"left and right side; instead got "+n.size()+", "+i.size());if(0===n.size()||0===i.size())throw new Error("must select at least one key column to join by");return{left:n,right:i}}function P(t,e){if(Ut(t)||null===t)return null;var r=H(t,e);if(!Ut(r))return r;var n=G(Ce.INT,e);return Q(t,n)}function Y(t,e,r){if(Ut(t)||null===t)return null;var n=e.size(),i=H(t,n);if(!Ut(i))return i;var o=G(Ce.COL,n,e._getIndex(),r);return Q(t,o)}function H(t,e){if(t.type===te.type){var r=H(t._selector,e);return Ut(r)?void 0:J(r,e)}if(Array.isArray(t)&&(t=bt(t.slice(),"object")),t.type===Yt.type&&"boolean"===t.dtype){if(t.size()!==e)throw new Error("inappropriate boolean indexer length ("+t.size()+"); expected length to be "+e);return t.which()}}function J(t,e){return Pt.seq(e).isIn(t).not().which()}function G(t,e,r,n){return r=Ut(r)?null:r,n=Ut(n)?null:n,{resolveMode:t,maxLen:e,index:r,dtypes:n}}function Q(t,e){var r=[];return X(t,e,r),ut(r,"number")}function X(t,e,r){if(null!==t&&"object"==typeof t){if("function"==typeof t._resolveSelectorHelper)return void t._resolveSelectorHelper(e,r);if(Array.isArray(t)){for(var n=0;n<t.length;n++)X(t[n],e,r);return}}var i;switch(e.resolveMode){case Ce.INT:r.push($(t,e.maxLen));break;case Ce.COL:if(Bt(t))r.push($(t,e.maxLen));else{if(!Ft(t)&&null!==t)throw new Error("expected integer or string selector but got: "+t);i=e.index.lookupKey([t]),tt(i,t,e,r)}break;case Ce.KEY:if(1!==e.index.arity)throw new Error("unimplemented case (TODO)");var o=e.index.initVectors[0].dtype;kt(t,o),i=e.index.lookupKey([t]),tt(i,t,e,r);break;default:throw new Error("Unrecognized RESOLVE_MODE: "+e.resolveMode)}}function Z(t,e,r,n){var i;if(Ut(t))return r?e.maxLen:0;var o=e.resolveMode===Ce.INT||e.resolveMode===Ce.COL&&"number"==typeof t;if(null===n&&(n=!o),o)return i=$(t,e.maxLen,!1),r&&n?i+1:i;if(1===e.index.arity){if(i=e.index.lookupKey([t]),null===i)throw new Error("could not find entry for range bound: "+t);return"number"==typeof i?r&&n?i+1:i:r&&n?i[i.length-1]+1:i[0]}throw new Error("unimplemented case (TODO)")}function $(t,e,r){if(Ut(r)&&(r=!0),!Number.isInteger(t))throw new Error("expected integer selector for integer indexing "+"but got non-integer: "+t);var n=0>t?e+t:t;if(r&&(0>n||n>=e))throw new Error("integer index out of bounds");return n}function tt(t,e,r,n){if(null===t)throw r.resolveMode===Ce.COL?new Error('could not find column named "'+e+'"'):new Error("could find entry for key: "+e);if("number"==typeof t)n.push(t);else for(var i=0;i<t.length;i++)n.push(t[i])}function et(t,e){if(Ut(t))throw new Error("selector must not be undefined");if(t=Lt(t),Bt(t))return $(t,e.values.length);if(Ft(t)||null===t){var r=e._getIndex().lookupKey([t]);if(null===r)throw new Error("invalid column name: "+t);return"number"!=typeof r&&(r=r[0]),r}throw new Error("column selector must be an integer or string")}function rt(t,e){return null===t?Me["null"]:Ut(t)?Me.undefined:"date"===e?t.valueOf():t}function nt(t){var e=t.length;if(0===e)throw new Error("cannot index an empty list of vectors");var r=t[0].size(),n=Object.create(re);n.initVectors=t,n.size=0,n.arity=e,n._dtypes=t.map(function(t){return t.dtype}),n._map=Object.create(null);for(var i=n._map,o=e-1,u=0;r>u;u++){for(var s,a,l=i,c=0;o>c;c++){s=t[c],a=rt(s.values[u],s.dtype);var h=l[a];Ut(h)&&(l[a]=h=Object.create(null)),l=h}s=t[o],a=rt(s.values[u],s.dtype);var f=l[a];Ut(f)?(l[a]=u,n.size++):"number"==typeof f?l[a]=[f,u]:f.push(u)}return n}function it(t){return null===t||Ut(t)||Number.isNaN(t)}function ot(t){return 64e3>t?new Array(t):[]}function ut(t,e){Ct(e);var r=oe[e],n=Object.create(r);return n._init(t),n}function st(t,e,r){for(var n=t.length,i=ot(n),o=0;n>o;o++){var u=t[o];i[o]=it(u)?e:r(u)}return i}function at(t,e,r){for(var n=e,i=0;i<t.length;i++){var o=t[i];it(o)||(n=r(n,o))}return n}function lt(t,e,r,n){for(var i=e,o=0;o<t.length;o++){var u=t[o];if(r(u))return u;i=n(i,u)}return i}function ct(t,e,r,n){var i=!0;Ut(n)&&(n=r,i=!1);for(var o=t.length,u=e.length,s=qt(o,u),a=1===o,l=1===u,c=ot(s),h=0;s>h;h++){var f=a?t[0]:t[h],v=l?e[0]:e[h];i&&(it(f)||it(v))?c[h]=r:c[h]=n(f,v)}return c}function ht(t,e,r){if(0===t.length)throw new Error("cannot combine an empty list of arrays");r=Ut(r)?null:r;var n,i=t.length,o=ot(i),u=1;for(n=0;i>n;n++)if(1===t[n].length)o[n]=!0;else if(o[n]=!1,1===u)u=t[n].length;else if(u!==t[n].length)throw new Error("length mismatch: expected "+u+" elements but found "+t[n].length);for(var s=ot(u),a=ot(i),l=0;u>l;l++){for(n=0;i>n;n++)a[n]=o[n]?t[n][0]:t[n][l];s[l]=e.apply(r,a)}return s}function ft(t,e,r){var n=!1;Ut(r)&&(r=e,n=!0);for(var i=t.length,o=ot(i),u=null,s=!1,a=0;i>a;a++){var l=t[a];if(it(l)){if(o[a]=l,!n){for(var c=a+1;i>c;c++)o[c]=e;break}}else u=s?r(u,l):l,s=!0,o[a]=u}return o}function vt(t,e){for(var r=ot(e.length),n=0;n<e.length;n++)r[n]=t[e[n]];return r}function pt(t){return Pt.strCat("c",Pt.seq(t))}function dt(t){if(t.nUnique()!==t.values.length)throw new Error("duplicate occurrence of one or more columns "+"in selection")}function mt(t,e,r){var n,i=t.length;if(r=Ut(r)?!0:r){var o=1;for(n=0;i>n;n++){t[n]=Vt(t[n]);var u=t[n].values.length;if(1!==u)if(1===o)o=u;else if(u!==o)throw new Error("incompatible column lengths found during "+"data frame construction: "+o+", "+u)}if(1!==o)for(n=0;i>n;n++)if(1===t[n].values.length){for(var s=t[n].values[0],a=ot(o),l=0;o>l;l++)a[l]=s;t[n]=ut(a,t[n].dtype)}}var c=null;if(i>0)for(c=t[0].dtype,n=1;i>n;n++)if(t[n].dtype!==c){c=null;break}var h=Object.create(Xt);return h._cols=t,h._names=e,h._index=null,h.allDtype=c,h}function yt(t){return null===t||Ut(t)?null:Bt(t)?"number":Wt(t)?"boolean":Ft(t)?"string":Kt(t)?"date":"object"}function gt(t,e){Ct(e);for(var r=ue[e],n=0;n<t.length;n++)t[n]=r(t[n]);return ut(t,e)}function bt(t,e){Ut(e)&&(e="object");for(var r=null,n=0;n<t.length;n++){var i=yt(t[n]);if(null!==i&&(null===r&&(r=i),r!==i||"object"===i))return ut(t,"object")}var o;if(null===r){if(r=e,"object"!==r)for(o=ie[r],n=0;n<t.length;n++)t[n]=o;return ut(t,r)}if("object"!==r)for(o=ie[r],n=0;n<t.length;n++)it(t[n])&&(t[n]=o);return ut(t,r)}function wt(t){return it(t)?ie.number:+t}function _t(t){return it(t)?ie["boolean"]:!!t}function xt(t){return it(t)?ie.string:"object"!=typeof t?t.toString():Kt(t)?t.toISOString():t.toString()}function Nt(t){if(it(t))return ie.date;var e=new Date(t);return Number.isNaN(e.getTime())?null:e}function Et(t){return null===t?"null":Ut(t)?"undefined":"object"!=typeof t?t.toString():Kt(t)?t.toISOString():t.toString()}function Ot(t,e){var r=it(t),n=it(e);if(r&&n)t=ze[t],e=ze[e];else{if(r)return-1;if(n)return 1}return e>t?-1:t>e?1:0}function jt(t){return function(e,r){return-t(e,r)}}function At(t,e){if(t.length!==e.length)throw new Error('length of "ascending" must match the number of '+"sort columns");if(0===t.length)return null;for(var r=t[0].size(),n=ot(r),i=0;r>i;i++)n[i]=i;var o=e.map(function(t){return t?Ot:Se}),u=function(e,r){for(var n=0,i=0;i<o.length;i++){var u=t[i].values[e],s=t[i].values[r];if(n=o[i](u,s),0!==n)return n}return Ot(e,r)};return n.sort(u),n}function Ct(t){if(!(t in ne))throw new Error('invalid dtype: "'+t+'"')}function Mt(t,e){if(!Number.isInteger(t))throw new Error('expected an integer for "'+e+'" but got: '+t)}function zt(t,e){if(!Number.isInteger(t)||0>t)throw new Error('"'+e+'" must be a nonnegative integer')}function St(t,e){if("function"!=typeof t)throw new Error('"'+e+'" must be a function')}function kt(t,e){var r=yt(t);if(null!==r&&r!==e)throw new Error('expected scalar to match dtype "'+e+'" but instead got '+t+', which has dtype "'+r+'"')}function It(t,e){if(t.dtype!==e)throw new Error('expected vector dtype to be "'+e+'" but got "'+t.dtype+'"')}function Rt(t,e){if(t.dtype===e)throw new Error('unsupported operation for dtype "'+e+'"')}function Tt(t){if(t._dtypesVector().contains("object"))throw new Error("unsupported operation over data frame columns "+'with "object" dtype')}function qt(t,e){var r=t;if(t!==e)if(1===t)r=e;else if(1!==e)throw new Error("incompatible array lengths: "+t+" and "+e);return r}function Lt(t){if(Ut(t)||null===t)return t;var e=1,r="a scalar";if(t.type===Yt.type?(e=t.size(),t=t.values[0],r="a vector"):Array.isArray(t)&&(e=t.length,t=t[0],r="an array"),1!==e)throw new Error("expected a single scalar value but got "+r+" of length "+e);return t}function Vt(t,e){return(it(t)||t.type!==Yt.type)&&(t=Array.isArray(t)?bt(t.slice(),e):bt([t],e)),t}function Dt(t){return t=Vt(t,"string"),"string"!==t.dtype?t.toDtype("string"):t}function Bt(t){return"number"==typeof t}function Wt(t){return"boolean"==typeof t}function Ft(t){return"string"==typeof t}function Kt(t){return"[object Date]"===Object.prototype.toString.call(t)}function Ut(t){return"undefined"==typeof t}var Pt=t,Yt={};Yt.type="jsdataframe.Vector";var Ht=Object.create(Yt),Jt=Object.create(Yt),Gt=Object.create(Yt),Qt=Object.create(Yt),Xt={};Xt.type="jsdataframe.DataFrame";var Zt={};Zt.type="jsdataframe.Range";var $t={};$t.type="jsdataframe.ByDtype";var te={};te.type="jsdataframe.Exclusion";var ee={};ee.type="jsdataframe.AbstractIndex";var re=Object.create(ee);re.type="jsdataframe.NestedIndex";var ne=Object.create(null);ne.number=!0,ne["boolean"]=!0,ne.string=!0,ne.date=!0,ne.object=!0;var ie={number:NaN,"boolean":null,string:null,date:null,object:null},oe={number:Ht,"boolean":Jt,string:Gt,date:Qt,object:Yt},ue={number:wt,"boolean":_t,string:xt,date:Nt,object:function(t){return t}};Pt._private_export={},Pt.vector=function(t,e,r){if(!Array.isArray(t))throw new Error('"array" argument must be an Array');return(Ut(r)||r)&&(t=t.slice()),Ut(e)&&(e=null),null===e?bt(t):gt(t,e)},Pt.seq=function(t,r,n,i){if(1===arguments.length){if(!Bt(t))throw new Error('both "start" and "stop" arguments must be '+"specified for non-numeric sequences");r=t,t=0}else if(yt(t)!==yt(r))throw new Error('"start" and "stop" must have the same dtype');if(n=Ut(n)?1:n,i=Ut(i)?!1:i,Ft(t)){if(1!==t.length||1!==r.length)throw new Error('both "start" and "stop" must be single characters '+"for character sequences");var o=Pt.seq(t.charCodeAt(0),r.charCodeAt(0),n,i);return o.map(e)}if(0===n)throw new Error('"step" must be nonzero');if(r>t&&0>n)throw new Error('"step" must be positive when start < stop');if(t>r&&n>0)throw new Error('"step" must be negative when start > stop');for(var u=[],s=t;n>0?i?r>=s:r>s:i?s>=r:s>r;)u.push(s),s+=n;return ut(u,"number")},Pt.seqOut=function(t,r,n){if(arguments.length<3&&(n=1),n=+n,zt(r,"lengthOut"),Ft(t)){if(1!==t.length)throw new Error('"start" must be a single character '+"for character sequences");var i=Pt.seqOut(t.charCodeAt(0),r,n);return i.map(e)}for(var o=ot(r),u=t,s=0;r>s;s++)o[s]=u,u+=n;return ut(o,"number")},Pt.linspace=function(t,e,r){t=+t,e=+e,zt(r,"length");for(var n=ot(r),i=1===r?0:(e-t)/(r-1),o=0;r>o;o++)n[o]=t+o*i;return ut(n,"number")},Pt.rep=function(t,e){zt(e,"times"),t=Vt(t);for(var r=t.values,n=r.length,i=ot(n*e),o=0;e>o;o++)for(var u=o*n,s=0;n>s;s++)i[u+s]=r[s];return ut(i,t.dtype)},Pt.repEach=function(t,e){zt(e,"times"),t=Vt(t);for(var r=t.values,n=r.length,i=ot(n*e),o=0;n>o;o++)for(var u=o*e,s=0;e>s;s++)i[u+s]=r[o];return ut(i,t.dtype)},Pt.repNa=function(t,e){zt(t,"times"),Ct(e);for(var r=ie[e],n=ot(t),i=0;t>i;i++)n[i]=r;return ut(n,e)},Pt.df=function(t,e){Ut(e)||(e=Dt(e));var r;if(t.type===Yt.type)throw new Error('"columns" should not itself be a vector');if(Array.isArray(t)){if(r=t.length,Ut(e))e=pt(r);else if(e.size()!==r)throw new Error('the length of "colNames" ('+e.size()+') does not match the length of "columns" ('+r+")")}else{if("object"!=typeof t)throw new Error('expected "columns" to be an array or object but got: ',t);var n=Object.keys(t);r=n.length;var i=t;if(Ut(e))e=ut(n,"string");else{if(e.isNa().any())throw new Error('"colNames" cannot have null entries when '+'"columns" is an object');if(e.duplicated().any())throw new Error('"colNames" cannot have duplicate entries when '+'"columns" is an object');if(e.size()!==r||e.isIn(n).not().any())throw new Error('"colNames" must match all the keys in '+'"columns" if "columns" is an object')}t=ot(r);for(var o=0;r>o;o++)t[o]=i[e.values[o]]}return mt(t,e)},Pt.dfFromObjArray=function(t,e){if(!Array.isArray(t))throw new Error('"objArray" must be an array');var r,n,i=t.length,o=!0;if(Ut(e))e=[],n=[],o=!1;else{if(e=Dt(e),e.isNa().any())throw new Error('"colOrder" cannot have null entries');if(e.duplicated().any())throw new Error('"colOrder" cannot have duplicate entries');for(e=e.values,n=ot(e.length),r=0;r<e.length;r++)n[r]=ot(i)}for(var u=Object.create(null),s=0;i>s;s++){var a=t[s];if(!o){var l=Object.keys(a);for(r=0;r<l.length;r++){var c=l[r];if(!(c in u)){e.push(c);for(var h=ot(i),f=0;s>f;f++)h[f]=null;n.push(h),u[c]=c}}}for(r=0;r<e.length;r++)n[r][s]=a.propertyIsEnumerable(e[r])?a[e[r]]:null}return mt(n,ut(e,"string"))},Pt.dfFromMatrix=function(t,e){if(!Array.isArray(t))throw new Error('"matrix" must be an array');var n=t.length>0?t[0].length:0;if(e=Ut(e)?pt(n):Dt(e),n>0&&n!==e.size())throw new Error('"colNames" must have the same length as each '+"row array");return r(t,0,e)},Pt.dfFromMatrixWithHeader=function(t){if(!Array.isArray(t))throw new Error('"matrix" must be an array');if(0===t.length)throw new Error('"matrix" must not have length 0');var e=Dt(t[0]);if(t.length>1&&e.size()!==t[1].length)throw new Error("header row must have the same length as other "+"row arrays");return r(t,1,e)},Pt.vCat=function(){for(var t=arguments.length,e=ot(t),r=null,n=0,i=0;t>i;i++){var o=arguments[i];if(!Ut(o)&&null!==o&&o.type===Xt.type)throw new Error("cannot pass data frame arguments to jd.vCat");var u=Vt(o);null===r&&"object"!==u.dtype&&(r=u.dtype),n+=u.size(),e[i]=u}r=null===r?"object":r;var s=ot(n),a=0;for(i=0;t>i;i++)for(var l=e[i].values,c=l.length,h=0;c>h;h++)s[a]=l[h],a++;return bt(s,r)},Pt.colCat=function(){for(var t=arguments.length,e=ot(t),r=0;t>r;r++)e[r]=arguments[r];return Pt._colCatArray(e)},Pt._colCatArray=function(t){for(var e,r=t.length,n=[],i=[],o=0;r>o;o++){var u=t[o];if(Ut(u)||null===u)n.push(u),i.push(null);else if(u.type===Xt.type){var s=u._cols.length;for(e=0;s>e;e++)n.push(u._cols[e]),i.push(u._names.values[e])}else if("object"!=typeof u||u.type===Yt.type||Array.isArray(u))n.push(u),i.push(null);else{var a=Object.keys(u);for(e=0;e<a.length;e++){var l=a[e];n.push(u[l]),i.push(l)}}}return mt(n,ut(i,"string"))},Pt.rowCat=function(){for(var t=arguments.length,e=ot(t),r=0;t>r;r++)e[r]=arguments[r];return Pt._rowCatArray(e)};var se={SCALAR:0,ARRAY:1,VECTOR:2,DATA_FRAME:3};Pt._rowCatArray=function(t){var e,r,n,i=t.length,o=ot(i),u=null,s=0,a=-1;for(r=0;i>r;r++){e=t[r];var l;if(Ut(e)||null===e||"object"!=typeof e)o[r]=se.SCALAR,s++,l=a;else if(e.type===Xt.type){if(o[r]=se.DATA_FRAME,l=e.nCol(),0===l)continue;if(s+=e.nRow(),null===u)u=e._names.values.slice();else{var c=Math.min(u.length,l),h=e._names.values;for(n=0;c>n;n++)h[n]!==u[n]&&(u[n]=null)}}else e.type===Yt.type?(o[r]=se.VECTOR,s++,l=e.values.length):Array.isArray(e)?(o[r]=se.ARRAY,s++,l=e.length):(o[r]=se.SCALAR,s++,l=a);if(a===-1)a=l;else if(a!==l)throw new Error("arguments imply differing number of columns: "+a+", "+l)}if(0===s)return Pt.df([]);a===-1&&(a=1);var f=null===u?Pt.repNa(a,"string"):ut(u,"string"),v=ot(a);for(n=0;a>n;n++)v[n]=ot(s);var p=0;for(r=0;i>r;r++)switch(e=t[r],o[r]){case se.SCALAR:for(n=0;a>n;n++)v[n][p]=e;p++;break;case se.VECTOR:e=e.values;case se.ARRAY:for(n=0;a>n;n++)v[n][p]=e[n];p++;break;case se.DATA_FRAME:var d=e.nRow();for(n=0;a>n;n++)for(var m=0;d>m;m++)v[n][p+m]=e._cols[n].values[m];p+=d}return mt(v,f)},Pt.strCat=function(){var t=arguments.length;if(0===t)throw new Error('"strCat" must be called with at least one argument');for(var e=ot(t),r=0;t>r;r++)e[r]=Vt(arguments[r]).values;var n=Object.create(null),i=ht(e,ae,n);return ut(i,"string")};var ae=F(function(){for(var t=arguments.length,e=ot(t),r=0;t>r;r++){var n=arguments[r];if(it(n))return null;e[r]=Et(n)}return e.join("")}),le=55,ce=4,he=45,fe=6,ve=6,pe=Math.pow(10,1-fe),de=1e7-1e-9,me=" ",ye="..",ge=":";Pt.printingOpts={},Pt.printingOpts._maxWidth=79,Pt.printingOpts._maxLines=10,Pt.printingOpts._printCallback=function(t){console.log(t)},Pt.printingOpts.getMaxWidth=function(){return this._maxWidth},Pt.printingOpts.setMaxWidth=function(t){a(t,le,"maxWidth"),this._maxWidth=t},Pt.printingOpts.getMaxLines=function(){return this._maxLines},Pt.printingOpts.setMaxLines=function(t){a(t,ce,"maxLines"),this._maxLines=t},Pt.printingOpts.setPrintFunction=function(t){St(t,"callback"),this._printCallback=t},Yt.p=function(t){var e=this.printToString(t);Pt.printingOpts._printCallback(e)},Yt.printToString=function(t){if(Ut(t)?t=Pt.printingOpts._maxLines:a(t,ce,"maxLines"),0===this.values.length)return this.toString();var e=o(u(this.values.length,t)),r=o(this._toTruncatedPrintVector(t)),n=Pt.strCat(e,me,r);return this.toString()+"\n"+n.strJoin("\n")},Xt.p=function(t){var e=this.printToString(t);Pt.printingOpts._printCallback(e)},Xt.printToString=function(t){Ut(t)?t=Pt.printingOpts._maxLines:a(t,ce,"maxLines");for(var e=o(Pt.vCat("",u(this.nRow(),t))),r=[e],n=0,i=e.at(0).length,l=Pt.printingOpts._maxWidth-ye.length-me.length;l>=i&&n<this.nCol();){var c=this._cols[n]._toTruncatedPrintVector(t),h=o(Pt.vCat(s(this._names.at(n)),c));r.push(me),r.push(h),i+=me.length+h.at(0).length,n++}i>l&&(r.pop(),r.push(ye));var f=Pt.strCat.apply(Pt,r);return this.toString()+"\n"+f.strJoin("\n")},Yt._toTruncatedPrintVector=function(t){if(this.values.length>t){var e=Math.ceil(t/2-1),r=Pt.rng(0,e),n=Pt.rng(-e),i=this.s(Pt.rngCat(r,n))._toPrintVector();return Pt.vCat(i.s(r),ye,i.s(n))}return this._toPrintVector()},Yt._toPrintVector=function(){return this.map(s)},Ht._toPrintVector=function(){if(this.values.some(n)||this.values.some(i))return this.map(function(t){return t.toExponential(ve)});var t=Math.min(fe,this.map(l).max());return this.map(function(e){return e.toFixed(t)})},Pt._private_export.toPrintString=s,Pt._private_export.fractionDigits=l,Yt.dtype="object",Yt._init=function(t){this.values=t,this._index=null},Yt.size=function(){return this.values.length},Yt.toString=function(){return"Vector[dtype:"+this.dtype+", size:"+this.values.length+"]"},Yt.toArray=function(){return this.values.slice()},Yt.toDtype=function(t){if(this.dtype===t)return this;if("string"===t){var e=Object.create(null),r=ht([this.values],be,e);return ut(r,"string")}return Pt.vector(this.values,t)};var be=F(xt);Yt.serialize=function(){throw new Error("unimplemented method (TODO)")},Yt.isNa=function(){return ut(this.values.map(it),"boolean")},Yt.dropNa=function(){return this.filter(c)},Yt.replaceNa=function(t){var e=ue[this.dtype];t=e(t);for(var r=this.values.slice(),n=0;n<r.length;n++)it(r[n])&&(r[n]=t);return ut(r,this.dtype)},Yt.s=function(t){var e=P(t,this.values.length);if(null===e)return this;var r=vt(this.values,e.values);return ut(r,this.dtype)},Yt.sMod=function(t,e){var r=P(t,this.values.length);null===r&&(r=Pt.seq(this.values.length)),e=Vt(e,this.dtype),It(e,this.dtype);var n=1===e.size();if(!n&&e.size()!==r.size())throw new Error("length mismatch: cannot assign "+e.size()+" values to a selection of length "+r.size());for(var i=r.values,o=this.values.slice(),u=0;u<i.length;u++)o[i[u]]=n?e.values[0]:e.values[u];return ut(o,this.dtype)},Yt.at=function(t){return t=Lt(t),t=$(t,this.size()),this.values[t]},Yt.head=function(t){return Ut(t)&&(t=6),Mt(t,"n"),this.s(Pt.rng(0,t))},Yt.tail=function(t){Ut(t)&&(t=6),Mt(t,"n");var e=0>t?-t:this.size()-t;return this.s(Pt.rng(e,void 0))},Yt.ifElse=function(t,e){if(t=Vt(t,"boolean"),t.size()!==this.size())throw new Error('"cond" must be the same length as this vector');It(t,"boolean"),e=Vt(e,this.dtype),It(e,this.dtype);var r=ht([this.values,t.values,e.values,[ie[this.dtype]]],h);return ut(r,this.dtype)},Yt.ex=function(){return Pt.ex(this)},Yt.map=function(){var t=Array.prototype.map.apply(this.values,arguments);return bt(t,this.dtype)},Yt.reduce=function(){return Array.prototype.reduce.apply(this.values,arguments)},Yt.reduceRight=function(){return Array.prototype.reduceRight.apply(this.values,arguments)},Yt.findIndex=function(){return Array.prototype.findIndex.apply(this.values,arguments)},Yt.sort=function(t){Ut(t)&&(t=Ot);var e=this.values.slice();return Array.prototype.sort.call(e,t),ut(e,this.dtype)},Yt.reverse=function(){var t=this.values.slice();return Array.prototype.reverse.call(t),ut(t,this.dtype)},Yt.filter=function(){var t=Array.prototype.filter.apply(this.values,arguments);return ut(t,this.dtype)},Yt.strJoin=function(t){return this.values.map(Et).join(t)},Yt.combine=function(){var t=arguments.length;if(2>t)throw new Error('must supply at least one "varg"');var e=arguments[t-1];if("function"!=typeof e)throw new Error('the last argument to "combine" must be a function');var r=ot(t);r[0]=this.values;for(var n=1;t>n;n++)r[n]=Vt(arguments[n-1]).values;var i=ht(r,e);return Pt.vector(i)},Yt.eq=function(t){t=Vt(t,this.dtype);var e=qt(this.size(),t.size());if(this.dtype!==t.dtype)return Pt.repNa(e,"boolean");var r="object"===this.dtype?ct(this.values,t.values,null,v):ct(this.values,t.values,null,f);return ut(r,"boolean")},Yt.neq=function(t){return this.eq(t).not()},Yt.lt=function(t){t=Vt(t,this.dtype);var e=qt(this.size(),t.size());if(this.dtype!==t.dtype)return Pt.repNa(e,"boolean");var r=ct(this.values,t.values,null,p);return ut(r,"boolean")},Yt.gt=function(t){t=Vt(t,this.dtype);var e=qt(this.size(),t.size());if(this.dtype!==t.dtype)return Pt.repNa(e,"boolean");var r=ct(this.values,t.values,null,d);return ut(r,"boolean")},Yt.lte=function(t){return this.lt(t).or(this.eq(t))},Yt.gte=function(t){return this.gt(t).or(this.eq(t))},Yt.between=function(t,e,r){throw new Error("unimplemented method (TODO)")},Yt.equals=function(t,e){if(it(t)||t.type!==Yt.type||this.size()!==t.size()||this.dtype!==t.dtype)return!1;if(this===t)return!0;var r=f;"number"===this.dtype?r=Ut(e)?m:function(t,r){return Number.isNaN(t)&&Number.isNaN(r)||Math.abs(t-r)<=e}:"object"===this.dtype&&(r=v);for(var n=this.values,i=t.values,o=0;o<n.length;o++)if(!r(n[o],i[o]))return!1;return!0},Yt.min=function(t){var e=this.idxMin(t);return Number.isNaN(e)?ie[this.dtype]:this.values[e]},Yt.max=function(t){var e=this.idxMax(t);return Number.isNaN(e)?ie[this.dtype]:this.values[e]},Yt.cuMin=function(t){Ut(t)&&(t=!0);var e=t?ft(this.values,y):ft(this.values,ie[this.dtype],y);return ut(e,this.dtype)},Yt.cuMax=function(t){Ut(t)&&(t=!0);var e=t?ft(this.values,g):ft(this.values,ie[this.dtype],g);return ut(e,this.dtype)},Yt.idxMin=function(t){Ut(t)&&(t=!0);for(var e=this.values,r=NaN,n=null,i=0;i<e.length;i++){var o=e[i];if(it(o)){if(!t)return NaN}else(Ot(o,n)<0||Number.isNaN(r))&&(n=o,r=i)}return r},Yt.idxMax=function(t){Ut(t)&&(t=!0);for(var e=this.values,r=NaN,n=null,i=0;i<e.length;i++){var o=e[i];if(it(o)){if(!t)return NaN}else(Ot(o,n)>0||Number.isNaN(r))&&(n=o,r=i)}return r},Yt.pMin=function(t){t=Vt(t,this.dtype),It(t,this.dtype);var e=ct(this.values,t.values,ie[this.dtype],y);return ut(e,this.dtype)},Yt.pMax=function(t){t=Vt(t,this.dtype),It(t,this.dtype);var e=ct(this.values,t.values,ie[this.dtype],g);return ut(e,this.dtype)},Yt.clip=function(t,e){t=Vt(t,this.dtype),e=Vt(e,this.dtype),It(t,this.dtype),It(e,this.dtype);var r=ht([this.values,t.values,e.values],b);return ut(r,this.dtype)},Yt.rank=function(){throw new Error("unimplemented method (TODO)")},Yt.contains=function(t){Rt(this,"object"),t=Lt(t);var e=yt(t);if(e!==this.dtype&&null!==e)throw new Error('"value" does not match the dtype of this vector');return null!==this._getIndex().lookupKey([t])},Yt.isIn=function(t){return Rt(this,"object"),t=Vt(t,this.dtype),It(t,this.dtype),t._getIndex().has([this])},Yt.valueCounts=function(){Rt(this,"object");var t=this._getIndex().valueCounts(),e=Pt.df([t.vectors[0],t.counts],["value","count"]);return e.sort(["count","value"],[!1,!0])},Yt.unique=function(){return Rt(this,"object"),this._getIndex().unique()[0]},Yt.nUnique=function(){return Rt(this,"object"),this._getIndex().size},Yt.duplicated=function(t){return Rt(this,"object"),this._getIndex().duplicated(t)},Yt.intersect=function(){throw new Error("unimplemented method (TODO)")},Yt.replace=function(){throw new Error("unimplemented method (TODO)")},Yt.describe=function(){throw new Error("unimplemented method (TODO)")},Yt._getIndex=function(){return null===this._index&&(this._index=nt([this])),this._index},Ht.dtype="number",Ht.add=function(t){t=Vt(t,"number"),It(t,"number");var e=ct(this.values,t.values,NaN,w);return ut(e,"number")},Ht.sub=function(t){t=Vt(t,"number"),It(t,"number");var e=ct(this.values,t.values,NaN,_);return ut(e,"number")},Ht.mul=function(t){t=Vt(t,"number"),It(t,"number");var e=ct(this.values,t.values,NaN,x);return ut(e,"number")},Ht.div=function(t){t=Vt(t,"number"),It(t,"number");var e=ct(this.values,t.values,NaN,N);return ut(e,"number")},Ht.mod=function(t){t=Vt(t,"number"),It(t,"number");var e=ct(this.values,t.values,NaN,E);return ut(e,"number")},Ht.pow=function(t){t=Vt(t,"number"),It(t,"number");var e=ct(this.values,t.values,NaN,Math.pow);return ut(e,"number")},Ht.abs=function(){return ut(this.values.map(Math.abs),"number")},Ht.sqrt=function(){return ut(this.values.map(Math.sqrt),"number")},Ht.sign=function(){return ut(this.values.map(Math.sign),"number")},Ht.ceil=function(){return ut(this.values.map(Math.ceil),"number")},Ht.floor=function(){return ut(this.values.map(Math.floor),"number")},Ht.round=function(){return ut(this.values.map(Math.round),"number")},Ht.exp=function(){return ut(this.values.map(Math.exp),"number")},Ht.log=function(){return ut(this.values.map(Math.log),"number")},Ht.sin=function(){return ut(this.values.map(Math.sin),"number")},Ht.cos=function(){return ut(this.values.map(Math.cos),"number")},Ht.tan=function(){return ut(this.values.map(Math.tan),"number")},Ht.asin=function(){return ut(this.values.map(Math.asin),"number")},Ht.acos=function(){return ut(this.values.map(Math.acos),"number")},Ht.atan=function(){return ut(this.values.map(Math.atan),"number")},Ht.sum=function(t){return Ut(t)&&(t=!0),t?at(this.values,0,w):lt(this.values,0,it,w)},Ht.cuSum=function(t){Ut(t)&&(t=!0);var e=t?ft(this.values,w):ft(this.values,ie.number,w);return ut(e,"number")},Ht.mean=function(t){Ut(t)&&(t=!0);var e={n:0,sum:0},r=t?at(this.values,e,O):lt(this.values,e,it,O);return Number.isNaN(r)||0===r.n?NaN:r.sum/r.n},Ht.stdev=function(t){var e=this["var"](t);return Number.isNaN(e)?NaN:Math.sqrt(e)},Ht["var"]=function(t){Ut(t)&&(t=!0);var e={n:0,mean:0,M2:0},r=t?at(this.values,e,j):lt(this.values,e,it,j);return Number.isNaN(r)||r.n<2?NaN:r.M2/(r.n-1)},Jt.dtype="boolean",Jt.and=function(t){t=Vt(t,"boolean"),It(t,"boolean");var e=ct(this.values,t.values,A);return ut(e,"boolean")},Jt.or=function(t){t=Vt(t,"boolean"),It(t,"boolean");var e=ct(this.values,t.values,C);return ut(e,"boolean")},Jt.not=function(){var t=st(this.values,null,M);return ut(t,"boolean")},Jt.xor=function(t){t=Vt(t,"boolean"),It(t,"boolean");var e=ct(this.values,t.values,z);return ut(e,"boolean")},Jt.all=function(t){return Ut(t)&&(t=!1),t?at(this.values,!0,A):this.values.reduce(A,!0)},Jt.any=function(t){return Ut(t)&&(t=!1),t?at(this.values,!1,C):this.values.reduce(C,!1)},Jt.sum=function(t){if(Ut(t)&&(t=!0),t)return at(this.values,0,S);var e=lt(this.values,0,it,S);return null===e?NaN:e},Jt.which=function(){for(var t=[],e=0;e<this.values.length;e++){var r=this.values[e];r===!0&&t.push(e)}return ut(t,"number")},Gt.dtype="string",Gt.nChar=function(){var t=st(this.values,ie.number,k);return ut(t,"number")},Gt.charAt=function(t){t=Vt(t);var e=Object.create(null),r=ht([this.values,t.values],we,e);return ut(r,"string")};var we=F(function(t,e){return null===t?null:t.charAt(e)});Gt.trim=function(){var t=Object.create(null),e=ht([this.values],_e,t);return ut(e,"string")};var _e=F(function(t){return null===t?null:t.trim(); | ||
| });Gt.strSlice=function(t,e){t=Vt(t),e=Vt(e);var r=Object.create(null),n=ht([this.values,t.values,e.values],xe,r);return ut(n,"string")};var xe=F(function(t,e,r){return null===t?null:t.slice(e,r)});Gt.substr=function(t,e){t=Vt(t),e=Vt(e);var r=Object.create(null),n=ht([this.values,t.values,e.values],Ne,r);return ut(n,"string")};var Ne=F(function(t,e,r){return null===t?null:t.substr(e,r)});Gt.strIncludes=function(t,e){t=Vt(t),e=Vt(e);var r=ht([this.values,t.values,e.values],I);return ut(r,"boolean")},Gt.startsWith=function(t,e){t=Vt(t),e=Vt(e);var r=ht([this.values,t.values,e.values],R);return ut(r,"boolean")},Gt.endsWith=function(t,e){t=Vt(t),e=Vt(e);var r=ht([this.values,t.values,e.values],T);return ut(r,"boolean")},Gt.strIndexOf=function(t,e){t=Vt(t),e=Vt(e);var r=ht([this.values,t.values,e.values],q);return ut(r,"number")},Gt.strLastIndexOf=function(t,e){t=Vt(t),e=Vt(e);var r=ht([this.values,t.values,e.values],L);return ut(r,"number")},Gt.regexMatch=function(t){t=Vt(t);var e=Object.create(null),r=ht([this.values,t.values],Ee,e);return ut(r,"string")};var Ee=F(function(t,e){if(null===t)return null;var r=t.match(e);return null===r?null:r[0]});Gt.regexSearch=function(t){t=Vt(t);var e=ht([this.values,t.values],V);return ut(e,"number")},Gt.regexTest=function(t){t=Vt(t);var e=ht([this.values,t.values],D);return ut(e,"boolean")},Gt.strReplace=function(t,e){t=Vt(t),e=Vt(e);var r=Object.create(null),n=ht([this.values,t.values,e.values],Oe,r);return ut(n,"string")};var Oe=F(function(t,e,r){return null===t?null:t.replace(e,r)});Gt.toLowerCase=function(){var t=Object.create(null),e=ht([this.values],B,t);return ut(e,"string")},Gt.toUpperCase=function(){var t=Object.create(null),e=ht([this.values],W,t);return ut(e,"string")},Qt.dtype="date",Xt.nRow=function(){return 0===this._cols.length?0:this._cols[0].values.length},Xt.nCol=function(){return this._cols.length},Xt.dtypes=function(){return Pt.df([this.names(),this._dtypesVector()],["colName","dtype"])},Xt._dtypesVector=function(){return ut(this._cols.map(function(t){return t.dtype}),"string")},Xt.colArray=function(){return this._cols.slice()},Xt.colMap=function(){var t=this._names.dropNa().unique().values,e=t.map(function(t){return et(t,this._names)},this),r=Object.create(null);return e.forEach(function(e,n){var i=t[n];r[i]=this._cols[e]},this),r},Xt.equals=function(t,e){if(null===t||Ut(t)||t.type!==Xt.type||!t.names().equals(this.names()))return!1;for(var r=this.nCol(),n=0;r>n;n++)if(!t._cols[n].equals(this._cols[n],e))return!1;return!0},Xt.toString=function(){var t="DataFrame[nRow:"+this.nRow()+", nCol:"+this.nCol()+", allDtype:"+this.allDtype+"]";return t},Xt.toObjArray=function(){for(var t=this._names.dropNa().unique().values,e=t.map(function(t){return et(t,this._names)},this),r=this.nRow(),n=t.length,i=ot(r),o=0;r>o;o++){for(var u={},s=0;n>s;s++)u[t[s]]=this._cols[e[s]].values[o];i[o]=u}return i},Xt.toMatrix=function(t){t=Ut(t)?!1:t;var e=t?1:0,r=this.nRow(),n=ot(r+e);t&&(n[0]=this._names.values);for(var i=this.nCol(),o=0;r>o;o++){for(var u=ot(i),s=0;i>s;s++)u[s]=this._cols[s].values[o];n[o+e]=u}return n},Xt.names=function(){return this._names},Xt.setNames=function(t){if(t=Dt(t),t.size()!==this._cols.length)throw new Error('the length of "names" must match the number of columns');return mt(this._cols,t,!1)},Xt.rename=function(t){throw new Error("unimplemented method (TODO)")},Xt.resetNames=function(){return mt(this._cols,pt(this._cols.length),!1)},Xt.isNa=function(){return this.mapCols(function(t){return t.isNa()})},Xt.dropNa=function(){var t=this.nCol(),e=this.nRow();if(0===e)return this;for(var r=ot(e),n=0;e>n;n++){r[n]=!0;for(var i=0;t>i;i++)if(it(this._cols[i].values[n])){r[n]=!1;break}}return this.s(r)},Xt.s=function(t,e){var r=P(t,this.nRow()),n=Y(e,this._names,this._dtypesVector()),i=this._names.values,o=this._cols;null!==n&&(i=vt(i,n.values),o=vt(o,n.values));var u=ut(i,"string");if(null!==r){null===n&&(o=o.slice());for(var s=0;s<o.length;s++){var a=o[s].dtype,l=vt(o[s].values,r.values);o[s]=ut(l,a)}}return mt(o,u,!1)},Xt.sMod=function(t,e,r){var n=!Ut(r)&&null!==r&&r.type===Xt.type;n||(r=Lt(r));var i=P(t,this.nRow()),o=Y(e,this._names,this._dtypesVector());if(null===o?o=Pt.seq(this.nCol()):dt(o),n){var u=null===i?this.nRow():i.size();if(u!==r.nRow()||o.size()!==r.nCol())throw new Error('"values" has the wrong dimensions for selection')}for(var s=this._cols.slice(),a=0;a<o.values.length;a++){var l=o.values[a],c=n?r._cols[a]:r;s[l]=null!==i?s[l].sMod(i,c):n?c:Pt.rep(c,this.nRow())}return mt(s,this.names(),!1)},Xt.c=function(t){var e=et(t,this._names);return this._cols[e]},Xt.cMod=function(t,e){var r=this._cols.slice(),n=et(t,this._names);return r[n]=e,mt(r,this._names)},Xt.insertCol=function(t,e,r){if(t=xt(t),r=Ut(r)?this._cols.length:r,r=Lt(r),!Number.isInteger(r))throw new Error('expected "index" to be an integer but got: '+r);var n=this._cols.slice(),i=this._names.values.slice();return n.splice(r,0,e),i.splice(r,0,t),mt(n,ut(i,"string"))},Xt.at=function(t,e){if(t=Lt(t),t=$(t,this.nRow()),e=Lt(e),Bt(e))e=$(e,this.nCol());else{if(!Ft(e)&&null!==e)throw new Error('expected "j" to be an integer or string but got: '+e);e=et(e,this._names)}return this._cols[e].values[t]},Xt.head=function(t){return Ut(t)&&(t=6),Mt(t,"n"),this.s(Pt.rng(0,t))},Xt.tail=function(t){Ut(t)&&(t=6),Mt(t,"n");var e=0>t?-t:this.nRow()-t;return this.s(Pt.rng(e,void 0))},Xt.mapCols=function(t,e){arguments.length<2&&(e=t,t=null),St(e,"func");var r=Y(t,this._names,this._dtypesVector());null===r&&(r=Pt.seq(this._cols.length));for(var n=this._names.values,i=r.values.length,o=ot(i),u=ot(i),s=0;i>s;s++){var a=r.values[s],l=this._cols[a],c=n[a];u[s]=e(l,c,a,s),o[s]=c}var h=ut(o,"string");return mt(u,h)},Xt.updateCols=function(t,e){arguments.length<2&&(e=t,t=null),St(e,"func");var r=Y(t,this._names,this._dtypesVector());null===r?r=Pt.seq(this._cols.length):dt(r);for(var n=this._names.values,i=this._cols.slice(),o=r.values.length,u=0;o>u;u++){var s=r.values[u],a=this._cols[s],l=n[s];i[s]=e(a,l,s,u)}return mt(i,this._names)},Xt.mapRowObjects=function(t,e){return St(t,"func"),this.toObjArray().map(t,e)},Xt.mapRowArrays=function(t,e){return St(t,"func"),this.toMatrix().map(t,e)},Xt.mapRowVectors=function(t,e){St(t,"func");var r=this.allDtype;if(null===r)throw new Error('cannot call "mapRowVectors" on a data frame with '+'null "allDtype" property');for(var n=this.toMatrix(),i=0;i<n.length;i++)n[i]=ut(n[i],r);return n.map(t,e)},Xt.unique=function(){if(0===this.nCol())return this;Tt(this);var t=this._getIndex().unique();return mt(t,this._names,!1)},Xt.nUnique=function(){return 0===this.nCol()?0:(Tt(this),this._getIndex().size)},Xt.duplicated=function(t){return 0===this.nCol()?ut([],"boolean"):(Tt(this),this._getIndex().duplicated(t))},Xt._getIndex=function(){return 1===this._cols.length?this._cols[0]._getIndex():(null===this._index&&(this._index=nt(this._cols)),this._index)},Xt.groupApply=function(t,e,r){if(Ut(t))throw new Error('"colSelect" must not be undefined');var n=Y(t,this._names,this._dtypesVector());if(dt(n),null===n||n.size()===this.nCol())throw new Error('"colSelect" must not select every column in the '+"data frame");if(0===n.size())throw new Error('"colSelect" must select at least 1 column');var i=this.s(null,n.ex()),o=this.s(null,n);Tt(o);var u=o._getIndex(),s=o.unique();St(e,"func"),Ut(r)||(r=Vt(r,"string"),"string"!==r.dtype&&(r=r.toDtype("string")));for(var a=s.nRow(),l=ot(a),c=-1,h=0,f=0;a>f;f++){var v=s.s(f),p=u.lookup(s._cols,f),d=i.s(p),m=e(d,v);if(!Ut(m)){var y,g;if(null===m?(y=1,g=[v,m]):m.type===Xt.type?(y=m.nCol(),g=[v,m]):m.type===Yt.type?(y=m.size(),g=[v].concat(m.values)):Array.isArray(m)?(y=m.length,g=[v].concat(m)):(y=1,g=[v,m]),c===-1){if(c=y,!Ut(r)&&y!==r.size())throw new Error('length of "colNames" must match implied number '+'of columns returned by "func"')}else if(y!==c)throw new Error("inconsistent implied column counts returned from "+'"func": '+c+", ",+y);l[h]=Pt._colCatArray(g),h++}}if(0===h)return s.s([]);l.length!==h&&(l.length=h);var b=Pt._rowCatArray(l);if(!Ut(r)){var w=b.names();w=w.sMod(Pt.rng(n.size()),r),b=b.setNames(w)}return b},Xt.transpose=function(t,e){if(0===this.nRow())return Pt.df([]);if(t=Ut(t)?null:t,null!==t&&!Ft(t))throw new Error('"preservedColName" must be a string when not null or '+"undefined");var r,n,i=this.nRow();if(Ut(e))r=this,n=pt(i);else{var o=et(e,this._names);r=this.s(null,Pt.ex(o)),n=this.c(o),"string"!==n.dtype&&(n=n.toDtype("string"))}var u,s;null!==t?(n=Pt.vCat(t,n),u=1,s=ot(i+1),s[0]=r._names):(u=0,s=ot(i));for(var a=r.nCol(),l=0;i>l;l++){for(var c=ot(a),h=0;a>h;h++)c[h]=r._cols[h].values[l];s[l+u]=c}return mt(s,n)},Xt.sort=function(t,e){if(Ut(t))throw new Error('"colSelect" must not be undefined');var r=Y(t,this._names,this._dtypesVector());null===r?r=Pt.seq(this.nCol()):dt(r);var n=this.s(null,r);if(Tt(n),e=Ut(e)?!0:e,e=Vt(e,"boolean"),It(e,"boolean"),e.isNa().any())throw new Error('"ascending" must not contain missing values');1===e.size()&&(e=Pt.rep(e,n.nCol()));var i=At(n._cols,e.values);return this.s(i)};var je=Pt.vector(["by","leftBy","rightBy","leftSuffix","rightSuffix","indicator"]);Xt.join=function(t,e,r){if(Ut(t)||null===t||t.type!==Xt.type)throw new Error('"other" must be a data frame');var n=!1,i="_x",o="_y",u=!1,s=!1;switch(e){case"inner":break;case"left":u=!0;break;case"right":s=!0;break;case"outer":u=!0,s=!0;break;default:throw new Error('"how" must be one of the following strings: '+'"inner", "left", "right", "outer"')}if(!Ut(r)){var a=Pt.vector(Object.keys(r)),l=a.s(a.isIn(je).not());if(l.size()>0)throw new Error('invalid properties found int "opts": '+l.strJoin(", "));Ut(r.indicator)||(n=r.indicator),Ut(r.leftSuffix)||(i=r.leftSuffix),Ut(r.rightSuffix)||(o=r.rightSuffix)}var c=U(this,t,r),h=c.left,f=c.right,v=this.s(null,h),p=this.s(null,h.ex()),d=t.s(null,f),m=t.s(null,f.ex());if(v.dtypes().c("dtype").contains("object")||d.dtypes().c("dtype").contains("object"))throw new Error('key columns must not have "object" dtype');if(!v.dtypes().c("dtype").equals(d.dtypes().c("dtype")))throw new Error("key columns must have matching dtypes on left "+"and right");var y,g,b=p.names().s(p.names().isIn(m.names())),w=p.names().map(function(t){return b.contains(t)?t+i:t}),_=m.names().map(function(t){return b.contains(t)?t+o:t}),x=Pt.vCat(v.names(),w,_,n?["_join"]:[]),N=d._getIndex(),E=v.nRow(),O=ot(x.size());for(g=0;g<O.length;g++)O[g]=[];if(s)for(y=ot(d.nRow()),g=0;g<y.length;g++)y[g]=!0;for(g=0;E>g;g++){var j=N.lookup(v._cols,g);if(null===j)u&&K(O,v,p,m,g,null,"leftOnly");else if("number"==typeof j)K(O,v,p,m,g,j,"both"),s&&(y[j]=!1);else for(var A=0;A<j.length;A++){var C=j[A];K(O,v,p,m,g,C,"both"),s&&(y[C]=!1)}}if(s){var M=d.s(y),z=m.s(y);for(E=M.nRow(),g=0;E>g;g++)K(O,M,p,z,null,g,"rightOnly",!0)}return mt(O,x)},Pt.rng=function(t,e,r){if(r=Ut(r)?null:r,null!==r&&"boolean"!=typeof r)throw new Error('"includeStop" must be either true, false, or null');var n=Bt(t)&&Ft(e)||Ft(t)&&Bt(e);if(n&&null===r)throw new Error('"includeStop" must be set to either true or false '+"when mixing numbers and strings for start/stop");var i=Object.create(Zt);return i._start=t,i._stop=e,i._includeStop=r,i},Zt.ex=function(){return Pt.ex(this)};var Ae=Pt.vector(Object.keys(ne));Pt.byDtype=function(t){t=Vt(t),It(t,"string"),t=t.unique();var e=t.isIn(Ae);if(!e.all()){var r=t.s(e.not()).at(0);throw new Error('invalid dtype: ""'+r+'"')}var n=Object.create($t);return n._dtypes=t,n},$t.ex=function(){return Pt.ex(this)},Pt.ex=function(t){if(Ut(t))throw new Error('"selector" must not be undefined');var e=Object.create(te);return e._selector=t,e};var Ce={INT:"INT",COL:"COL",KEY:"KEY"};Yt._resolveSelectorHelper=function(t,e){var r,n,i="number"===this.dtype,o="string"===this.dtype;switch(t.resolveMode){case Ce.INT:if(!i)throw new Error("expected number vector for integer indexing "+'but got vector with dtype: "'+this.dtype+'"');for(r=0;r<this.values.length;r++)e.push($(this.values[r],t.maxLen));break;case Ce.COL:if(i)for(r=0;r<this.values.length;r++)e.push($(this.values[r],t.maxLen));else{if(!o)throw new Error("expected number or string vector for column "+'indexing but got vector with dtype: "'+this.dtype+'"');for(r=0;r<this.values.length;r++){var u=this.values[r];n=t.index.lookupKey([u]),tt(n,u,t,e)}}break;case Ce.KEY:if(1!==t.index.arity)throw new Error("unimplemented case (TODO)");var s=t.index.initVectors[0].dtype;if(this.dtype!==s)throw new Error('expected "'+s+'" vector for key '+'lookup but got vector with dtype: "'+this.dtype+'"');var a=[this];for(r=0;r<this.values.length;r++)n=t.index.lookup(a,r),tt(n,this.values[r],t,e);break;default:throw new Error("Unrecognized RESOLVE_MODE: "+t.resolveMode)}},Zt._resolveSelectorHelper=function(t,e){var r=Z(this._start,t,!1);if(!(r>=t.maxLen)){var n=Z(this._stop,t,!0,this._includeStop);if(!(0>=n)){r=0>r?0:r,n=n>t.maxLen?t.maxLen:n;for(var i=r;n>i;i++)e.push(i)}}},$t._resolveSelectorHelper=function(t,e){if(null===t.dtypes)throw new Error("ByDtype selector can only be used for column indexing");for(var r=t.dtypes.isIn(this._dtypes).which(),n=0;n<r.values.length;n++)e.push(r.values[n])},te._resolveSelectorHelper=function(t,e){var r=[];X(this._selector,t,r);for(var n=J(ut(r,"number"),t.maxLen),i=0;i<n.values.length;i++)e.push(n.values[i])},ee.lookup=function(t,e){throw new Error('abstract "lookup" method called without concrete '+"implementation")},ee.has=function(t){for(var e=t[0].size(),r=ot(e),n=0;e>n;n++)r[n]=null!==this.lookup(t,n);return ut(r,"boolean")},ee.valueCounts=function(){for(var t=this.initVectors,e=this.arity,r=this.size,n=ot(e),i=0;e>i;i++)n[i]=ot(r);for(var o=ot(r),u=t[0].size(),s=0,a=0;u>a;a++){var l=this.lookup(t,a);if(l===a||l[0]===a){for(i=0;e>i;i++)n[i][s]=t[i].values[a];o[s]=l===a?1:l.length,s++}}var c=n.map(function(e,r){return ut(e,t[r].dtype)});return{vectors:c,counts:ut(o,"number")}},ee.unique=function(){return this.valueCounts().vectors},ee.duplicated=function(t){Ut(t)&&(t="first");var e=!1,r=!1;if("first"===t)e=!0;else if("last"===t)r=!0;else if(t!==!1)throw new Error('"keep" must be either "first", "last", or false');for(var n=this.initVectors,i=n[0].size(),o=ot(i),u=0;i>u;u++)o[u]=!1;var s=e?1:0;for(u=0;i>u;u++){var a=this.lookup(n,u);if("number"!=typeof a&&a[0]===u)for(var l=a.length,c=r?l-1:l,h=s;c>h;h++)o[a[h]]=!0}return ut(o,"boolean")};var Me={"null":"_INTERNAL_JSDATAFRAME_NULL_KEY_",undefined:"_INTERNAL_JSDATAFRAME_UNDEFINED_KEY_"};Pt._private_export.newNestedIndex=nt,re.lookup=function(t,e){for(var r=this.arity,n=this._dtypes,i=this._map,o=0;r>o;o++){var u=t[o],s=rt(u.values[e],n[o]);if(i=i[s],Ut(i))return null}return i},re.lookupKey=function(t){for(var e=this.arity,r=this._dtypes,n=this._map,i=0;e>i;i++){var o=rt(t[i],r[i]);if(n=n[o],Ut(n))return null}return n},Pt._private_export.mapNonNa=st,Pt._private_export.reduceNonNa=at,Pt._private_export.reduceUnless=lt,Pt._private_export.combineArrays=ct,Pt._private_export.inferDtype=yt,Pt._private_export.inferVectorDtype=bt,Pt._private_export.coerceToNum=wt,Pt._private_export.coerceToBool=_t,Pt._private_export.coerceToStr=xt,Pt._private_export.coerceToDate=Nt;var ze={undefined:0,"null":1,NaN:2};Pt._private_export.compare=Ot;var Se=jt(Ot);Pt._private_export.reverseComp=jt,Pt._private_export.ensureVector=Vt,Number.isNaN=Number.isNaN||function(t){return t!==t},Number.isInteger=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},Array.prototype.findIndex||(Array.prototype.findIndex=function(t){if(null===this)throw new TypeError("Array.prototype.findIndex called on null or undefined");if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e,r=Object(this),n=r.length>>>0,i=arguments[1],o=0;n>o;o++)if(e=r[o],t.call(i,e,o,r))return o;return-1}),String.prototype.includes||(String.prototype.includes=function(t,e){return"number"!=typeof e&&(e=0),e+t.length>this.length?!1:this.indexOf(t,e)!==-1}),String.prototype.startsWith||(String.prototype.startsWith=function(t,e){return e=e||0,this.substr(e,t.length)===t}),String.prototype.endsWith||(String.prototype.endsWith=function(t,e){var r=this.toString();("number"!=typeof e||!isFinite(e)||Math.floor(e)!==e||e>r.length)&&(e=r.length),e-=t.length;var n=r.indexOf(t,e);return n!==-1&&n===e})}); | ||
| !function(t,e){"function"==typeof define&&define.amd?define(["exports"],e):e("object"==typeof exports&&"string"!=typeof exports.nodeName?exports:t.jsdataframe={})}(this,function(t){"use strict";function e(t){return String.fromCharCode(t)}function r(t,e,r){var n,i=r.size(),o=t.length-e,u=ot(i);for(n=0;i>n;n++)u[n]=ot(o);for(var s=0;o>s;s++){var a=t[s+e];if(a.length!==i)throw new Error("all row arrays must be of the same size");for(n=0;i>n;n++)u[n][s]=a[n]}return mt(u,r)}function n(t){return 0!==t&&Math.abs(t)<pe}function i(t){return Math.abs(t)>de}function o(t){var e=t.nChar().max(),r=Pt.rep(" ",e).strJoin("");return t.map(function(t){return(r+t).slice(-r.length)})}function u(t,e){var r=Pt.seq(t)._toTruncatedPrintVector(e);return r.map(function(t){return t===ye?t:t+ge})}function s(t){if(Ut(t))return"undefined";if(null===t)return"null";if(Number.isNaN(t))return"NaN";var e=xt(t),r=e.split("\n",2);return r.length>1&&(e=r[0]+"..."),e.length>he&&(e=e.slice(0,he-3)+"..."),e}function a(t,e,r){if("number"!=typeof t||Number.isNaN(t))throw new Error('"'+r+'" must be a number');if(e>t)throw new Error('"'+r+'" too small')}function l(t){var e=t.toString().split(".");return e.length>1?e[1].length:0}function c(t){return!it(t)}function h(t,e,r,n){return it(e)?n:e?t:r}function f(t,e){return 0===Ot(t,e)}function v(t,e){return Number.isNaN(t)&&Number.isNaN(e)||t===e}function p(t,e){return Ot(t,e)<0}function d(t,e){return Ot(t,e)>0}function m(t,e){return Number.isNaN(t)&&Number.isNaN(e)||Math.abs(t-e)<=1e-7}function y(t,e){return Ot(e,t)<0?e:t}function g(t,e){return Ot(e,t)>0?e:t}function b(t,e,r){var n=it(e),i=it(r);if(!n&&!i&&e>r)throw new Error("invalid range: lower ("+e+") > upper ("+r+")");return it(t)?t:!n&&e>t?e:!i&&t>r?r:t}function w(t,e){return t+e}function _(t,e){return t-e}function x(t,e){return t*e}function N(t,e){return t/e}function E(t,e){return t%e}function O(t,e){return t.n++,t.sum+=e,t}function j(t,e){t.n++;var r=e-t.mean;return t.mean+=r/t.n,t.M2+=r*(e-t.mean),t}function A(t,e){return t===!1||e===!1?!1:null===t||null===e?null:!0}function C(t,e){return t===!0||e===!0?!0:null===t||null===e?null:!1}function M(t){return!t}function z(t,e){return null===t||null===e?null:t!==e}function S(t,e){return+t+ +e}function k(t){return t.length}function I(t,e,r){return null===t?null:t.includes(e,r)}function R(t,e,r){return null===t?null:t.startsWith(e,r)}function T(t,e,r){return null===t?null:t.endsWith(e,r)}function q(t,e,r){return null===t?NaN:t.indexOf(e,r)}function L(t,e,r){return null===t?NaN:t.lastIndexOf(e,r)}function V(t,e){return null===t?NaN:t.search(e)}function D(t,e){return null===e||null===t?null:e.test(t)}function B(t){return null===t?null:t.toLowerCase()}function W(t){return null===t?null:t.toUpperCase()}function F(t){return function(){var e=t.apply(null,arguments);if(null===e)return e;var r=this[e];return Ut(r)&&(this[e]=e,r=e),r}}function K(t,e,r,n,i,o,u,s){var a,l,c=s?o:i,h=0;for(l=e.nCol(),a=0;l>a;a++)t[h].push(e._cols[a].values[c]),h++;for(l=r.nCol(),a=0;l>a;a++){var f=null===i?null:r._cols[a].values[i];t[h].push(f),h++}for(l=n.nCol(),a=0;l>a;a++){var v=null===o?null:n._cols[a].values[o];t[h].push(v),h++}h<t.length&&t[h].push(u)}function U(t,e,r){var n,i;if(Ut(r)||Ut(r.by)&&Ut(r.leftBy)&&Ut(r.rightBy)){var o=t.names().s(t.names().isIn(e.names()));if(o.nUnique()!==o.size())throw new Error("duplicate names found for key columns");n=Y(o,t._names,t._dtypesVector()),i=Y(o,e._names,e._dtypesVector())}else if(Ut(r.by)){if(Ut(r.leftBy)||Ut(r.rightBy))throw new Error("must specify both opts.leftBy and "+"opts.rightBy together");n=Y(r.leftBy,t._names,t._dtypesVector()),i=Y(r.rightBy,e._names,e._dtypesVector())}else{if(!Ut(r.leftBy)||!Ut(r.rightBy))throw new Error("cannot define opts.by, opts.leftBy, and "+"opts.rightBy all together");if(null!==r.by&&"object"==typeof r.by&&r.by.type!==Yt.type){var u=Object.keys(r.by),s=u.map(function(t){return r.by[t]});n=Y(u,t._names,t._dtypesVector()),i=Y(s,e._names,e._dtypesVector())}else{var a=Vt(r.by,"string");if(n=Y(a,t._names,t._dtypesVector()),i=Y(a,e._names,e._dtypesVector()),a.size()!==n.size())throw new Error("duplicate names found for key columns")}}if(dt(n),dt(i),n.size()!==i.size())throw new Error("must select the same number of key columns on the "+"left and right side; instead got "+n.size()+", "+i.size());if(0===n.size()||0===i.size())throw new Error("must select at least one key column to join by");return{left:n,right:i}}function P(t,e){if(Ut(t)||null===t)return null;var r=H(t,e);if(!Ut(r))return r;var n=G(Ce.INT,e);return Q(t,n)}function Y(t,e,r){if(Ut(t)||null===t)return null;var n=e.size(),i=H(t,n);if(!Ut(i))return i;var o=G(Ce.COL,n,e._getIndex(),r);return Q(t,o)}function H(t,e){if(t.type===te.type){var r=H(t._selector,e);return Ut(r)?void 0:J(r,e)}if(Array.isArray(t)&&(t=bt(t.slice(),"object")),t.type===Yt.type&&"boolean"===t.dtype){if(t.size()!==e)throw new Error("inappropriate boolean indexer length ("+t.size()+"); expected length to be "+e);return t.which()}}function J(t,e){return Pt.seq(e).isIn(t).not().which()}function G(t,e,r,n){return r=Ut(r)?null:r,n=Ut(n)?null:n,{resolveMode:t,maxLen:e,index:r,dtypes:n}}function Q(t,e){var r=[];return X(t,e,r),ut(r,"number")}function X(t,e,r){if(null!==t&&"object"==typeof t){if("function"==typeof t._resolveSelectorHelper)return void t._resolveSelectorHelper(e,r);if(Array.isArray(t)){for(var n=0;n<t.length;n++)X(t[n],e,r);return}}var i;switch(e.resolveMode){case Ce.INT:r.push($(t,e.maxLen));break;case Ce.COL:if(Bt(t))r.push($(t,e.maxLen));else{if(!Ft(t)&&null!==t)throw new Error("expected integer or string selector but got: "+t);i=e.index.lookupKey([t]),tt(i,t,e,r)}break;case Ce.KEY:if(1!==e.index.arity)throw new Error("unimplemented case (TODO)");var o=e.index.initVectors[0].dtype;kt(t,o),i=e.index.lookupKey([t]),tt(i,t,e,r);break;default:throw new Error("Unrecognized RESOLVE_MODE: "+e.resolveMode)}}function Z(t,e,r,n){var i;if(Ut(t))return r?e.maxLen:0;var o=e.resolveMode===Ce.INT||e.resolveMode===Ce.COL&&"number"==typeof t;if(null===n&&(n=!o),o)return i=$(t,e.maxLen,!1),r&&n?i+1:i;if(1===e.index.arity){if(i=e.index.lookupKey([t]),null===i)throw new Error("could not find entry for range bound: "+t);return"number"==typeof i?r&&n?i+1:i:r&&n?i[i.length-1]+1:i[0]}throw new Error("unimplemented case (TODO)")}function $(t,e,r){if(Ut(r)&&(r=!0),!Number.isInteger(t))throw new Error("expected integer selector for integer indexing "+"but got non-integer: "+t);var n=0>t?e+t:t;if(r&&(0>n||n>=e))throw new Error("integer index out of bounds");return n}function tt(t,e,r,n){if(null===t)throw r.resolveMode===Ce.COL?new Error('could not find column named "'+e+'"'):new Error("could find entry for key: "+e);if("number"==typeof t)n.push(t);else for(var i=0;i<t.length;i++)n.push(t[i])}function et(t,e){if(Ut(t))throw new Error("selector must not be undefined");if(t=Lt(t),Bt(t))return $(t,e.values.length);if(Ft(t)||null===t){var r=e._getIndex().lookupKey([t]);if(null===r)throw new Error("invalid column name: "+t);return"number"!=typeof r&&(r=r[0]),r}throw new Error("column selector must be an integer or string")}function rt(t,e){return null===t?Me["null"]:Ut(t)?Me.undefined:"date"===e?t.valueOf():t}function nt(t){var e=t.length;if(0===e)throw new Error("cannot index an empty list of vectors");var r=t[0].size(),n=Object.create(re);n.initVectors=t,n.size=0,n.arity=e,n._dtypes=t.map(function(t){return t.dtype}),n._map=Object.create(null);for(var i=n._map,o=e-1,u=0;r>u;u++){for(var s,a,l=i,c=0;o>c;c++){s=t[c],a=rt(s.values[u],s.dtype);var h=l[a];Ut(h)&&(l[a]=h=Object.create(null)),l=h}s=t[o],a=rt(s.values[u],s.dtype);var f=l[a];Ut(f)?(l[a]=u,n.size++):"number"==typeof f?l[a]=[f,u]:f.push(u)}return n}function it(t){return null===t||Ut(t)||Number.isNaN(t)}function ot(t){return 64e3>t?new Array(t):[]}function ut(t,e){Ct(e);var r=oe[e],n=Object.create(r);return n._init(t),n}function st(t,e,r){for(var n=t.length,i=ot(n),o=0;n>o;o++){var u=t[o];i[o]=it(u)?e:r(u)}return i}function at(t,e,r){for(var n=e,i=0;i<t.length;i++){var o=t[i];it(o)||(n=r(n,o))}return n}function lt(t,e,r,n){for(var i=e,o=0;o<t.length;o++){var u=t[o];if(r(u))return u;i=n(i,u)}return i}function ct(t,e,r,n){var i=!0;Ut(n)&&(n=r,i=!1);for(var o=t.length,u=e.length,s=qt(o,u),a=1===o,l=1===u,c=ot(s),h=0;s>h;h++){var f=a?t[0]:t[h],v=l?e[0]:e[h];i&&(it(f)||it(v))?c[h]=r:c[h]=n(f,v)}return c}function ht(t,e,r){if(0===t.length)throw new Error("cannot combine an empty list of arrays");r=Ut(r)?null:r;var n,i=t.length,o=ot(i),u=1;for(n=0;i>n;n++)if(1===t[n].length)o[n]=!0;else if(o[n]=!1,1===u)u=t[n].length;else if(u!==t[n].length)throw new Error("length mismatch: expected "+u+" elements but found "+t[n].length);for(var s=ot(u),a=ot(i),l=0;u>l;l++){for(n=0;i>n;n++)a[n]=o[n]?t[n][0]:t[n][l];s[l]=e.apply(r,a)}return s}function ft(t,e,r){var n=!1;Ut(r)&&(r=e,n=!0);for(var i=t.length,o=ot(i),u=null,s=!1,a=0;i>a;a++){var l=t[a];if(it(l)){if(o[a]=l,!n){for(var c=a+1;i>c;c++)o[c]=e;break}}else u=s?r(u,l):l,s=!0,o[a]=u}return o}function vt(t,e){for(var r=ot(e.length),n=0;n<e.length;n++)r[n]=t[e[n]];return r}function pt(t){return Pt.strCat("c",Pt.seq(t))}function dt(t){if(t.nUnique()!==t.values.length)throw new Error("duplicate occurrence of one or more columns "+"in selection")}function mt(t,e,r){var n,i=t.length;if(r=Ut(r)?!0:r){var o=1;for(n=0;i>n;n++){t[n]=Vt(t[n]);var u=t[n].values.length;if(1!==u)if(1===o)o=u;else if(u!==o)throw new Error("incompatible column lengths found during "+"data frame construction: "+o+", "+u)}if(1!==o)for(n=0;i>n;n++)if(1===t[n].values.length){for(var s=t[n].values[0],a=ot(o),l=0;o>l;l++)a[l]=s;t[n]=ut(a,t[n].dtype)}}var c=null;if(i>0)for(c=t[0].dtype,n=1;i>n;n++)if(t[n].dtype!==c){c=null;break}var h=Object.create(Xt);return h._cols=t,h._names=e,h._index=null,h.allDtype=c,h}function yt(t){return null===t||Ut(t)?null:Bt(t)?"number":Wt(t)?"boolean":Ft(t)?"string":Kt(t)?"date":"object"}function gt(t,e){Ct(e);for(var r=ue[e],n=0;n<t.length;n++)t[n]=r(t[n]);return ut(t,e)}function bt(t,e){Ut(e)&&(e="object");for(var r=null,n=0;n<t.length;n++){var i=yt(t[n]);if(null!==i&&(null===r&&(r=i),r!==i||"object"===i))return ut(t,"object")}var o;if(null===r){if(r=e,"object"!==r)for(o=ie[r],n=0;n<t.length;n++)t[n]=o;return ut(t,r)}if("object"!==r)for(o=ie[r],n=0;n<t.length;n++)it(t[n])&&(t[n]=o);return ut(t,r)}function wt(t){return it(t)?ie.number:+t}function _t(t){return it(t)?ie["boolean"]:!!t}function xt(t){return it(t)?ie.string:"object"!=typeof t?t.toString():Kt(t)?t.toISOString():t.toString()}function Nt(t){if(it(t))return ie.date;var e=new Date(t);return Number.isNaN(e.getTime())?null:e}function Et(t){return null===t?"null":Ut(t)?"undefined":"object"!=typeof t?t.toString():Kt(t)?t.toISOString():t.toString()}function Ot(t,e){var r=it(t),n=it(e);if(r&&n)t=ze[t],e=ze[e];else{if(r)return-1;if(n)return 1}return e>t?-1:t>e?1:0}function jt(t){return function(e,r){return-t(e,r)}}function At(t,e){if(t.length!==e.length)throw new Error('length of "ascending" must match the number of '+"sort columns");if(0===t.length)return null;for(var r=t[0].size(),n=ot(r),i=0;r>i;i++)n[i]=i;var o=e.map(function(t){return t?Ot:Se}),u=function(e,r){for(var n=0,i=0;i<o.length;i++){var u=t[i].values[e],s=t[i].values[r];if(n=o[i](u,s),0!==n)return n}return Ot(e,r)};return n.sort(u),n}function Ct(t){if(!(t in ne))throw new Error('invalid dtype: "'+t+'"')}function Mt(t,e){if(!Number.isInteger(t))throw new Error('expected an integer for "'+e+'" but got: '+t)}function zt(t,e){if(!Number.isInteger(t)||0>t)throw new Error('"'+e+'" must be a nonnegative integer')}function St(t,e){if("function"!=typeof t)throw new Error('"'+e+'" must be a function')}function kt(t,e){var r=yt(t);if(null!==r&&r!==e)throw new Error('expected scalar to match dtype "'+e+'" but instead got '+t+', which has dtype "'+r+'"')}function It(t,e){if(t.dtype!==e)throw new Error('expected vector dtype to be "'+e+'" but got "'+t.dtype+'"')}function Rt(t,e){if(t.dtype===e)throw new Error('unsupported operation for dtype "'+e+'"')}function Tt(t){if(t._dtypesVector().contains("object"))throw new Error("unsupported operation over data frame columns "+'with "object" dtype')}function qt(t,e){var r=t;if(t!==e)if(1===t)r=e;else if(1!==e)throw new Error("incompatible array lengths: "+t+" and "+e);return r}function Lt(t){if(Ut(t)||null===t)return t;var e=1,r="a scalar";if(t.type===Yt.type?(e=t.size(),t=t.values[0],r="a vector"):Array.isArray(t)&&(e=t.length,t=t[0],r="an array"),1!==e)throw new Error("expected a single scalar value but got "+r+" of length "+e);return t}function Vt(t,e){return(it(t)||t.type!==Yt.type)&&(t=Array.isArray(t)?bt(t.slice(),e):bt([t],e)),t}function Dt(t){return t=Vt(t,"string"),"string"!==t.dtype?t.toDtype("string"):t}function Bt(t){return"number"==typeof t}function Wt(t){return"boolean"==typeof t}function Ft(t){return"string"==typeof t}function Kt(t){return"[object Date]"===Object.prototype.toString.call(t)}function Ut(t){return"undefined"==typeof t}var Pt=t;Pt.version="0.1.1",Number.isNaN=Number.isNaN||function(t){return t!==t},Number.isInteger=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&Math.floor(t)===t},Array.prototype.findIndex||(Array.prototype.findIndex=function(t){if(null===this)throw new TypeError("Array.prototype.findIndex called on null or undefined");if("function"!=typeof t)throw new TypeError("predicate must be a function");for(var e,r=Object(this),n=r.length>>>0,i=arguments[1],o=0;n>o;o++)if(e=r[o],t.call(i,e,o,r))return o;return-1}),String.prototype.includes||(String.prototype.includes=function(t,e){return"number"!=typeof e&&(e=0),e+t.length>this.length?!1:this.indexOf(t,e)!==-1}),String.prototype.startsWith||(String.prototype.startsWith=function(t,e){return e=e||0,this.substr(e,t.length)===t}),String.prototype.endsWith||(String.prototype.endsWith=function(t,e){var r=this.toString();("number"!=typeof e||!isFinite(e)||Math.floor(e)!==e||e>r.length)&&(e=r.length),e-=t.length;var n=r.indexOf(t,e);return n!==-1&&n===e});var Yt={};Yt.type="jsdataframe.Vector";var Ht=Object.create(Yt),Jt=Object.create(Yt),Gt=Object.create(Yt),Qt=Object.create(Yt),Xt={};Xt.type="jsdataframe.DataFrame";var Zt={};Zt.type="jsdataframe.Range";var $t={};$t.type="jsdataframe.ByDtype";var te={};te.type="jsdataframe.Exclusion";var ee={};ee.type="jsdataframe.AbstractIndex";var re=Object.create(ee);re.type="jsdataframe.NestedIndex";var ne=Object.create(null);ne.number=!0,ne["boolean"]=!0,ne.string=!0,ne.date=!0,ne.object=!0;var ie={number:NaN,"boolean":null,string:null,date:null,object:null},oe={number:Ht,"boolean":Jt,string:Gt,date:Qt,object:Yt},ue={number:wt,"boolean":_t,string:xt,date:Nt,object:function(t){return t}};Pt._private_export={},Pt.vector=function(t,e,r){if(!Array.isArray(t))throw new Error('"array" argument must be an Array');return(Ut(r)||r)&&(t=t.slice()),Ut(e)&&(e=null),null===e?bt(t):gt(t,e)},Pt.seq=function(t,r,n,i){if(1===arguments.length){if(!Bt(t))throw new Error('both "start" and "stop" arguments must be '+"specified for non-numeric sequences");r=t,t=0}else if(yt(t)!==yt(r))throw new Error('"start" and "stop" must have the same dtype');if(n=Ut(n)?1:n,i=Ut(i)?!1:i,Ft(t)){if(1!==t.length||1!==r.length)throw new Error('both "start" and "stop" must be single characters '+"for character sequences");var o=Pt.seq(t.charCodeAt(0),r.charCodeAt(0),n,i);return o.map(e)}if(0===n)throw new Error('"step" must be nonzero');if(r>t&&0>n)throw new Error('"step" must be positive when start < stop');if(t>r&&n>0)throw new Error('"step" must be negative when start > stop');for(var u=[],s=t;n>0?i?r>=s:r>s:i?s>=r:s>r;)u.push(s),s+=n;return ut(u,"number")},Pt.seqOut=function(t,r,n){if(arguments.length<3&&(n=1),n=+n,zt(r,"lengthOut"),Ft(t)){if(1!==t.length)throw new Error('"start" must be a single character '+"for character sequences");var i=Pt.seqOut(t.charCodeAt(0),r,n);return i.map(e)}for(var o=ot(r),u=t,s=0;r>s;s++)o[s]=u,u+=n;return ut(o,"number")},Pt.linspace=function(t,e,r){t=+t,e=+e,zt(r,"length");for(var n=ot(r),i=1===r?0:(e-t)/(r-1),o=0;r>o;o++)n[o]=t+o*i;return ut(n,"number")},Pt.rep=function(t,e){zt(e,"times"),t=Vt(t);for(var r=t.values,n=r.length,i=ot(n*e),o=0;e>o;o++)for(var u=o*n,s=0;n>s;s++)i[u+s]=r[s];return ut(i,t.dtype)},Pt.repEach=function(t,e){zt(e,"times"),t=Vt(t);for(var r=t.values,n=r.length,i=ot(n*e),o=0;n>o;o++)for(var u=o*e,s=0;e>s;s++)i[u+s]=r[o];return ut(i,t.dtype)},Pt.repNa=function(t,e){zt(t,"times"),Ct(e);for(var r=ie[e],n=ot(t),i=0;t>i;i++)n[i]=r;return ut(n,e)},Pt.df=function(t,e){Ut(e)||(e=Dt(e));var r;if(t.type===Yt.type)throw new Error('"columns" should not itself be a vector');if(Array.isArray(t)){if(r=t.length,Ut(e))e=pt(r);else if(e.size()!==r)throw new Error('the length of "colNames" ('+e.size()+') does not match the length of "columns" ('+r+")")}else{if("object"!=typeof t)throw new Error('expected "columns" to be an array or object but got: ',t);var n=Object.keys(t);r=n.length;var i=t;if(Ut(e))e=ut(n,"string");else{if(e.isNa().any())throw new Error('"colNames" cannot have null entries when '+'"columns" is an object');if(e.duplicated().any())throw new Error('"colNames" cannot have duplicate entries when '+'"columns" is an object');if(e.size()!==r||e.isIn(n).not().any())throw new Error('"colNames" must match all the keys in '+'"columns" if "columns" is an object')}t=ot(r);for(var o=0;r>o;o++)t[o]=i[e.values[o]]}return mt(t,e)},Pt.dfFromObjArray=function(t,e){if(!Array.isArray(t))throw new Error('"objArray" must be an array');var r,n,i=t.length,o=!0;if(Ut(e))e=[],n=[],o=!1;else{if(e=Dt(e),e.isNa().any())throw new Error('"colOrder" cannot have null entries');if(e.duplicated().any())throw new Error('"colOrder" cannot have duplicate entries');for(e=e.values,n=ot(e.length),r=0;r<e.length;r++)n[r]=ot(i)}for(var u=Object.create(null),s=0;i>s;s++){var a=t[s];if(!o){var l=Object.keys(a);for(r=0;r<l.length;r++){var c=l[r];if(!(c in u)){e.push(c);for(var h=ot(i),f=0;s>f;f++)h[f]=null;n.push(h),u[c]=c}}}for(r=0;r<e.length;r++)n[r][s]=a.propertyIsEnumerable(e[r])?a[e[r]]:null}return mt(n,ut(e,"string"))},Pt.dfFromMatrix=function(t,e){if(!Array.isArray(t))throw new Error('"matrix" must be an array');var n=t.length>0?t[0].length:0;if(e=Ut(e)?pt(n):Dt(e),n>0&&n!==e.size())throw new Error('"colNames" must have the same length as each '+"row array");return r(t,0,e)},Pt.dfFromMatrixWithHeader=function(t){if(!Array.isArray(t))throw new Error('"matrix" must be an array');if(0===t.length)throw new Error('"matrix" must not have length 0');var e=Dt(t[0]);if(t.length>1&&e.size()!==t[1].length)throw new Error("header row must have the same length as other "+"row arrays");return r(t,1,e)},Pt.vCat=function(){for(var t=arguments.length,e=ot(t),r=null,n=0,i=0;t>i;i++){var o=arguments[i];if(!Ut(o)&&null!==o&&o.type===Xt.type)throw new Error("cannot pass data frame arguments to jd.vCat");var u=Vt(o);null===r&&"object"!==u.dtype&&(r=u.dtype),n+=u.size(),e[i]=u}r=null===r?"object":r;var s=ot(n),a=0;for(i=0;t>i;i++)for(var l=e[i].values,c=l.length,h=0;c>h;h++)s[a]=l[h],a++;return bt(s,r)},Pt.colCat=function(){for(var t=arguments.length,e=ot(t),r=0;t>r;r++)e[r]=arguments[r];return Pt._colCatArray(e)},Pt._colCatArray=function(t){for(var e,r=t.length,n=[],i=[],o=0;r>o;o++){var u=t[o];if(Ut(u)||null===u)n.push(u),i.push(null);else if(u.type===Xt.type){var s=u._cols.length;for(e=0;s>e;e++)n.push(u._cols[e]),i.push(u._names.values[e])}else if("object"!=typeof u||u.type===Yt.type||Array.isArray(u))n.push(u),i.push(null);else{var a=Object.keys(u);for(e=0;e<a.length;e++){var l=a[e];n.push(u[l]),i.push(l)}}}return mt(n,ut(i,"string"))},Pt.rowCat=function(){for(var t=arguments.length,e=ot(t),r=0;t>r;r++)e[r]=arguments[r];return Pt._rowCatArray(e)};var se={SCALAR:0,ARRAY:1,VECTOR:2,DATA_FRAME:3};Pt._rowCatArray=function(t){var e,r,n,i=t.length,o=ot(i),u=null,s=0,a=-1;for(r=0;i>r;r++){e=t[r];var l;if(Ut(e)||null===e||"object"!=typeof e)o[r]=se.SCALAR,s++,l=a;else if(e.type===Xt.type){if(o[r]=se.DATA_FRAME,l=e.nCol(),0===l)continue;if(s+=e.nRow(),null===u)u=e._names.values.slice();else{var c=Math.min(u.length,l),h=e._names.values;for(n=0;c>n;n++)h[n]!==u[n]&&(u[n]=null)}}else e.type===Yt.type?(o[r]=se.VECTOR,s++,l=e.values.length):Array.isArray(e)?(o[r]=se.ARRAY,s++,l=e.length):(o[r]=se.SCALAR,s++,l=a);if(a===-1)a=l;else if(a!==l)throw new Error("arguments imply differing number of columns: "+a+", "+l)}if(0===s)return Pt.df([]);a===-1&&(a=1);var f=null===u?Pt.repNa(a,"string"):ut(u,"string"),v=ot(a);for(n=0;a>n;n++)v[n]=ot(s);var p=0;for(r=0;i>r;r++)switch(e=t[r],o[r]){case se.SCALAR:for(n=0;a>n;n++)v[n][p]=e;p++;break;case se.VECTOR:e=e.values;case se.ARRAY:for(n=0;a>n;n++)v[n][p]=e[n];p++;break;case se.DATA_FRAME:var d=e.nRow();for(n=0;a>n;n++)for(var m=0;d>m;m++)v[n][p+m]=e._cols[n].values[m];p+=d}return mt(v,f)},Pt.strCat=function(){var t=arguments.length;if(0===t)throw new Error('"strCat" must be called with at least one argument');for(var e=ot(t),r=0;t>r;r++)e[r]=Vt(arguments[r]).values;var n=Object.create(null),i=ht(e,ae,n);return ut(i,"string")};var ae=F(function(){for(var t=arguments.length,e=ot(t),r=0;t>r;r++){var n=arguments[r];if(it(n))return null;e[r]=Et(n)}return e.join("")}),le=55,ce=4,he=45,fe=6,ve=6,pe=Math.pow(10,1-fe),de=1e7-1e-9,me=" ",ye="..",ge=":";Pt.printingOpts={},Pt.printingOpts._maxWidth=79,Pt.printingOpts._maxLines=10,Pt.printingOpts._printCallback=function(t){console.log(t)},Pt.printingOpts.getMaxWidth=function(){return this._maxWidth},Pt.printingOpts.setMaxWidth=function(t){a(t,le,"maxWidth"),this._maxWidth=t},Pt.printingOpts.getMaxLines=function(){return this._maxLines},Pt.printingOpts.setMaxLines=function(t){a(t,ce,"maxLines"),this._maxLines=t},Pt.printingOpts.setPrintFunction=function(t){St(t,"callback"),this._printCallback=t},Yt.p=function(t){var e=this.printToString(t);Pt.printingOpts._printCallback(e)},Yt.printToString=function(t){if(Ut(t)?t=Pt.printingOpts._maxLines:a(t,ce,"maxLines"),0===this.values.length)return this.toString();var e=o(u(this.values.length,t)),r=o(this._toTruncatedPrintVector(t)),n=Pt.strCat(e,me,r);return this.toString()+"\n"+n.strJoin("\n")},Xt.p=function(t){var e=this.printToString(t);Pt.printingOpts._printCallback(e)},Xt.printToString=function(t){Ut(t)?t=Pt.printingOpts._maxLines:a(t,ce,"maxLines");for(var e=o(Pt.vCat("",u(this.nRow(),t))),r=[e],n=0,i=e.at(0).length,l=Pt.printingOpts._maxWidth-ye.length-me.length;l>=i&&n<this.nCol();){var c=this._cols[n]._toTruncatedPrintVector(t),h=o(Pt.vCat(s(this._names.at(n)),c));r.push(me),r.push(h),i+=me.length+h.at(0).length,n++}i>l&&(r.pop(),r.push(ye));var f=Pt.strCat.apply(Pt,r);return this.toString()+"\n"+f.strJoin("\n")},Yt._toTruncatedPrintVector=function(t){if(this.values.length>t){var e=Math.ceil(t/2-1),r=Pt.rng(0,e),n=Pt.rng(-e),i=this.s([r,n])._toPrintVector();return Pt.vCat(i.s(r),ye,i.s(n))}return this._toPrintVector()},Yt._toPrintVector=function(){return this.map(s)},Ht._toPrintVector=function(){if(this.values.some(n)||this.values.some(i))return this.map(function(t){return t.toExponential(ve)});var t=Math.min(fe,this.map(l).max());return this.map(function(e){return e.toFixed(t)})},Pt._private_export.toPrintString=s,Pt._private_export.fractionDigits=l,Yt.dtype="object",Yt._init=function(t){this.values=t,this._index=null},Yt.size=function(){return this.values.length},Yt.toString=function(){return"Vector[dtype:"+this.dtype+", size:"+this.values.length+"]"},Yt.toArray=function(){return this.values.slice()},Yt.toDtype=function(t){if(this.dtype===t)return this;if("string"===t){var e=Object.create(null),r=ht([this.values],be,e);return ut(r,"string")}return Pt.vector(this.values,t)};var be=F(xt);Yt.serialize=function(){throw new Error("unimplemented method (TODO)")},Yt.isNa=function(){return ut(this.values.map(it),"boolean")},Yt.dropNa=function(){return this.filter(c)},Yt.replaceNa=function(t){var e=ue[this.dtype];t=e(t);for(var r=this.values.slice(),n=0;n<r.length;n++)it(r[n])&&(r[n]=t);return ut(r,this.dtype)},Yt.s=function(t){var e=P(t,this.values.length);if(null===e)return this;var r=vt(this.values,e.values);return ut(r,this.dtype)},Yt.sMod=function(t,e){var r=P(t,this.values.length);null===r&&(r=Pt.seq(this.values.length)),e=Vt(e,this.dtype),It(e,this.dtype);var n=1===e.size();if(!n&&e.size()!==r.size())throw new Error("length mismatch: cannot assign "+e.size()+" values to a selection of length "+r.size());for(var i=r.values,o=this.values.slice(),u=0;u<i.length;u++)o[i[u]]=n?e.values[0]:e.values[u];return ut(o,this.dtype)},Yt.at=function(t){return t=Lt(t),t=$(t,this.size()),this.values[t]},Yt.head=function(t){return Ut(t)&&(t=6),Mt(t,"n"),this.s(Pt.rng(0,t))},Yt.tail=function(t){Ut(t)&&(t=6),Mt(t,"n");var e=0>t?-t:this.size()-t;return this.s(Pt.rng(e,void 0))},Yt.ifElse=function(t,e){if(t=Vt(t,"boolean"),t.size()!==this.size())throw new Error('"cond" must be the same length as this vector');It(t,"boolean"),e=Vt(e,this.dtype),It(e,this.dtype);var r=ht([this.values,t.values,e.values,[ie[this.dtype]]],h);return ut(r,this.dtype)},Yt.ex=function(){return Pt.ex(this)},Yt.map=function(){var t=Array.prototype.map.apply(this.values,arguments);return bt(t,this.dtype)},Yt.reduce=function(){return Array.prototype.reduce.apply(this.values,arguments)},Yt.reduceRight=function(){return Array.prototype.reduceRight.apply(this.values,arguments)},Yt.findIndex=function(){return Array.prototype.findIndex.apply(this.values,arguments)},Yt.sort=function(t){Ut(t)&&(t=Ot);var e=this.values.slice();return Array.prototype.sort.call(e,t),ut(e,this.dtype)},Yt.reverse=function(){var t=this.values.slice();return Array.prototype.reverse.call(t),ut(t,this.dtype)},Yt.filter=function(){var t=Array.prototype.filter.apply(this.values,arguments);return ut(t,this.dtype)},Yt.strJoin=function(t){return this.values.map(Et).join(t)},Yt.combine=function(){var t=arguments.length;if(2>t)throw new Error('must supply at least one "varg"');var e=arguments[t-1];if("function"!=typeof e)throw new Error('the last argument to "combine" must be a function');var r=ot(t);r[0]=this.values;for(var n=1;t>n;n++)r[n]=Vt(arguments[n-1]).values;var i=ht(r,e);return Pt.vector(i)},Yt.eq=function(t){t=Vt(t,this.dtype);var e=qt(this.size(),t.size());if(this.dtype!==t.dtype)return Pt.repNa(e,"boolean");var r="object"===this.dtype?ct(this.values,t.values,null,v):ct(this.values,t.values,null,f);return ut(r,"boolean")},Yt.neq=function(t){return this.eq(t).not()},Yt.lt=function(t){t=Vt(t,this.dtype);var e=qt(this.size(),t.size());if(this.dtype!==t.dtype)return Pt.repNa(e,"boolean");var r=ct(this.values,t.values,null,p);return ut(r,"boolean")},Yt.gt=function(t){t=Vt(t,this.dtype);var e=qt(this.size(),t.size());if(this.dtype!==t.dtype)return Pt.repNa(e,"boolean");var r=ct(this.values,t.values,null,d);return ut(r,"boolean")},Yt.lte=function(t){return this.lt(t).or(this.eq(t))},Yt.gte=function(t){return this.gt(t).or(this.eq(t))},Yt.between=function(t,e,r){throw new Error("unimplemented method (TODO)")},Yt.equals=function(t,e){if(it(t)||t.type!==Yt.type||this.size()!==t.size()||this.dtype!==t.dtype)return!1;if(this===t)return!0;var r=f;"number"===this.dtype?r=Ut(e)?m:function(t,r){return Number.isNaN(t)&&Number.isNaN(r)||Math.abs(t-r)<=e}:"object"===this.dtype&&(r=v);for(var n=this.values,i=t.values,o=0;o<n.length;o++)if(!r(n[o],i[o]))return!1;return!0},Yt.min=function(t){var e=this.idxMin(t);return Number.isNaN(e)?ie[this.dtype]:this.values[e]},Yt.max=function(t){var e=this.idxMax(t);return Number.isNaN(e)?ie[this.dtype]:this.values[e]},Yt.cuMin=function(t){Ut(t)&&(t=!0);var e=t?ft(this.values,y):ft(this.values,ie[this.dtype],y);return ut(e,this.dtype)},Yt.cuMax=function(t){Ut(t)&&(t=!0);var e=t?ft(this.values,g):ft(this.values,ie[this.dtype],g);return ut(e,this.dtype)},Yt.idxMin=function(t){Ut(t)&&(t=!0);for(var e=this.values,r=NaN,n=null,i=0;i<e.length;i++){var o=e[i];if(it(o)){if(!t)return NaN}else(Ot(o,n)<0||Number.isNaN(r))&&(n=o,r=i)}return r},Yt.idxMax=function(t){Ut(t)&&(t=!0);for(var e=this.values,r=NaN,n=null,i=0;i<e.length;i++){var o=e[i];if(it(o)){if(!t)return NaN}else(Ot(o,n)>0||Number.isNaN(r))&&(n=o,r=i)}return r},Yt.pMin=function(t){t=Vt(t,this.dtype),It(t,this.dtype);var e=ct(this.values,t.values,ie[this.dtype],y);return ut(e,this.dtype)},Yt.pMax=function(t){t=Vt(t,this.dtype),It(t,this.dtype);var e=ct(this.values,t.values,ie[this.dtype],g);return ut(e,this.dtype)},Yt.clip=function(t,e){t=Vt(t,this.dtype),e=Vt(e,this.dtype),It(t,this.dtype),It(e,this.dtype);var r=ht([this.values,t.values,e.values],b);return ut(r,this.dtype)},Yt.rank=function(){throw new Error("unimplemented method (TODO)")},Yt.contains=function(t){Rt(this,"object"),t=Lt(t);var e=yt(t);if(e!==this.dtype&&null!==e)throw new Error('"value" does not match the dtype of this vector');return null!==this._getIndex().lookupKey([t])},Yt.isIn=function(t){return Rt(this,"object"),t=Vt(t,this.dtype),It(t,this.dtype),t._getIndex().has([this])},Yt.valueCounts=function(){Rt(this,"object");var t=this._getIndex().valueCounts(),e=Pt.df([t.vectors[0],t.counts],["value","count"]);return e.sort(["count","value"],[!1,!0])},Yt.unique=function(){return Rt(this,"object"),this._getIndex().unique()[0]},Yt.nUnique=function(){return Rt(this,"object"),this._getIndex().size},Yt.duplicated=function(t){return Rt(this,"object"),this._getIndex().duplicated(t)},Yt.intersect=function(){throw new Error("unimplemented method (TODO)")},Yt.replace=function(){throw new Error("unimplemented method (TODO)")},Yt.describe=function(){throw new Error("unimplemented method (TODO)")},Yt._getIndex=function(){return null===this._index&&(this._index=nt([this])),this._index},Ht.dtype="number",Ht.add=function(t){t=Vt(t,"number"),It(t,"number");var e=ct(this.values,t.values,NaN,w);return ut(e,"number")},Ht.sub=function(t){t=Vt(t,"number"),It(t,"number");var e=ct(this.values,t.values,NaN,_);return ut(e,"number")},Ht.mul=function(t){t=Vt(t,"number"),It(t,"number");var e=ct(this.values,t.values,NaN,x);return ut(e,"number")},Ht.div=function(t){t=Vt(t,"number"),It(t,"number");var e=ct(this.values,t.values,NaN,N);return ut(e,"number")},Ht.mod=function(t){t=Vt(t,"number"),It(t,"number");var e=ct(this.values,t.values,NaN,E);return ut(e,"number")},Ht.pow=function(t){t=Vt(t,"number"),It(t,"number");var e=ct(this.values,t.values,NaN,Math.pow);return ut(e,"number")},Ht.abs=function(){return ut(this.values.map(Math.abs),"number")},Ht.sqrt=function(){return ut(this.values.map(Math.sqrt),"number")},Ht.sign=function(){return ut(this.values.map(Math.sign),"number")},Ht.ceil=function(){return ut(this.values.map(Math.ceil),"number")},Ht.floor=function(){return ut(this.values.map(Math.floor),"number")},Ht.round=function(){return ut(this.values.map(Math.round),"number")},Ht.exp=function(){return ut(this.values.map(Math.exp),"number")},Ht.log=function(){return ut(this.values.map(Math.log),"number")},Ht.sin=function(){return ut(this.values.map(Math.sin),"number")},Ht.cos=function(){return ut(this.values.map(Math.cos),"number")},Ht.tan=function(){return ut(this.values.map(Math.tan),"number")},Ht.asin=function(){return ut(this.values.map(Math.asin),"number")},Ht.acos=function(){return ut(this.values.map(Math.acos),"number")},Ht.atan=function(){return ut(this.values.map(Math.atan),"number")},Ht.sum=function(t){return Ut(t)&&(t=!0),t?at(this.values,0,w):lt(this.values,0,it,w)},Ht.cuSum=function(t){Ut(t)&&(t=!0);var e=t?ft(this.values,w):ft(this.values,ie.number,w);return ut(e,"number")},Ht.mean=function(t){Ut(t)&&(t=!0);var e={n:0,sum:0},r=t?at(this.values,e,O):lt(this.values,e,it,O);return Number.isNaN(r)||0===r.n?NaN:r.sum/r.n},Ht.stdev=function(t){var e=this["var"](t);return Number.isNaN(e)?NaN:Math.sqrt(e)},Ht["var"]=function(t){Ut(t)&&(t=!0);var e={n:0,mean:0,M2:0},r=t?at(this.values,e,j):lt(this.values,e,it,j);return Number.isNaN(r)||r.n<2?NaN:r.M2/(r.n-1)},Jt.dtype="boolean",Jt.and=function(t){t=Vt(t,"boolean"),It(t,"boolean");var e=ct(this.values,t.values,A);return ut(e,"boolean")},Jt.or=function(t){t=Vt(t,"boolean"),It(t,"boolean");var e=ct(this.values,t.values,C);return ut(e,"boolean"); | ||
| },Jt.not=function(){var t=st(this.values,null,M);return ut(t,"boolean")},Jt.xor=function(t){t=Vt(t,"boolean"),It(t,"boolean");var e=ct(this.values,t.values,z);return ut(e,"boolean")},Jt.all=function(t){return Ut(t)&&(t=!1),t?at(this.values,!0,A):this.values.reduce(A,!0)},Jt.any=function(t){return Ut(t)&&(t=!1),t?at(this.values,!1,C):this.values.reduce(C,!1)},Jt.sum=function(t){if(Ut(t)&&(t=!0),t)return at(this.values,0,S);var e=lt(this.values,0,it,S);return null===e?NaN:e},Jt.which=function(){for(var t=[],e=0;e<this.values.length;e++){var r=this.values[e];r===!0&&t.push(e)}return ut(t,"number")},Gt.dtype="string",Gt.nChar=function(){var t=st(this.values,ie.number,k);return ut(t,"number")},Gt.charAt=function(t){t=Vt(t);var e=Object.create(null),r=ht([this.values,t.values],we,e);return ut(r,"string")};var we=F(function(t,e){return null===t?null:t.charAt(e)});Gt.trim=function(){var t=Object.create(null),e=ht([this.values],_e,t);return ut(e,"string")};var _e=F(function(t){return null===t?null:t.trim()});Gt.strSlice=function(t,e){t=Vt(t),e=Vt(e);var r=Object.create(null),n=ht([this.values,t.values,e.values],xe,r);return ut(n,"string")};var xe=F(function(t,e,r){return null===t?null:t.slice(e,r)});Gt.substr=function(t,e){t=Vt(t),e=Vt(e);var r=Object.create(null),n=ht([this.values,t.values,e.values],Ne,r);return ut(n,"string")};var Ne=F(function(t,e,r){return null===t?null:t.substr(e,r)});Gt.strIncludes=function(t,e){t=Vt(t),e=Vt(e);var r=ht([this.values,t.values,e.values],I);return ut(r,"boolean")},Gt.startsWith=function(t,e){t=Vt(t),e=Vt(e);var r=ht([this.values,t.values,e.values],R);return ut(r,"boolean")},Gt.endsWith=function(t,e){t=Vt(t),e=Vt(e);var r=ht([this.values,t.values,e.values],T);return ut(r,"boolean")},Gt.strIndexOf=function(t,e){t=Vt(t),e=Vt(e);var r=ht([this.values,t.values,e.values],q);return ut(r,"number")},Gt.strLastIndexOf=function(t,e){t=Vt(t),e=Vt(e);var r=ht([this.values,t.values,e.values],L);return ut(r,"number")},Gt.regexMatch=function(t){t=Vt(t);var e=Object.create(null),r=ht([this.values,t.values],Ee,e);return ut(r,"string")};var Ee=F(function(t,e){if(null===t)return null;var r=t.match(e);return null===r?null:r[0]});Gt.regexSearch=function(t){t=Vt(t);var e=ht([this.values,t.values],V);return ut(e,"number")},Gt.regexTest=function(t){t=Vt(t);var e=ht([this.values,t.values],D);return ut(e,"boolean")},Gt.strReplace=function(t,e){t=Vt(t),e=Vt(e);var r=Object.create(null),n=ht([this.values,t.values,e.values],Oe,r);return ut(n,"string")};var Oe=F(function(t,e,r){return null===t?null:t.replace(e,r)});Gt.toLowerCase=function(){var t=Object.create(null),e=ht([this.values],B,t);return ut(e,"string")},Gt.toUpperCase=function(){var t=Object.create(null),e=ht([this.values],W,t);return ut(e,"string")},Qt.dtype="date",Xt.nRow=function(){return 0===this._cols.length?0:this._cols[0].values.length},Xt.nCol=function(){return this._cols.length},Xt.dtypes=function(){return Pt.df([this.names(),this._dtypesVector()],["colName","dtype"])},Xt._dtypesVector=function(){return ut(this._cols.map(function(t){return t.dtype}),"string")},Xt.colArray=function(){return this._cols.slice()},Xt.colMap=function(){var t=this._names.dropNa().unique().values,e=t.map(function(t){return et(t,this._names)},this),r=Object.create(null);return e.forEach(function(e,n){var i=t[n];r[i]=this._cols[e]},this),r},Xt.equals=function(t,e){if(null===t||Ut(t)||t.type!==Xt.type||!t.names().equals(this.names()))return!1;for(var r=this.nCol(),n=0;r>n;n++)if(!t._cols[n].equals(this._cols[n],e))return!1;return!0},Xt.toString=function(){var t="DataFrame[nRow:"+this.nRow()+", nCol:"+this.nCol()+", allDtype:"+this.allDtype+"]";return t},Xt.toObjArray=function(){for(var t=this._names.dropNa().unique().values,e=t.map(function(t){return et(t,this._names)},this),r=this.nRow(),n=t.length,i=ot(r),o=0;r>o;o++){for(var u={},s=0;n>s;s++)u[t[s]]=this._cols[e[s]].values[o];i[o]=u}return i},Xt.toMatrix=function(t){t=Ut(t)?!1:t;var e=t?1:0,r=this.nRow(),n=ot(r+e);t&&(n[0]=this._names.values);for(var i=this.nCol(),o=0;r>o;o++){for(var u=ot(i),s=0;i>s;s++)u[s]=this._cols[s].values[o];n[o+e]=u}return n},Xt.names=function(){return this._names},Xt.setNames=function(t){if(t=Dt(t),t.size()!==this._cols.length)throw new Error('the length of "names" must match the number of columns');return mt(this._cols,t,!1)},Xt.rename=function(t){throw new Error("unimplemented method (TODO)")},Xt.resetNames=function(){return mt(this._cols,pt(this._cols.length),!1)},Xt.isNa=function(){return this.mapCols(function(t){return t.isNa()})},Xt.dropNa=function(){var t=this.nCol(),e=this.nRow();if(0===e)return this;for(var r=ot(e),n=0;e>n;n++){r[n]=!0;for(var i=0;t>i;i++)if(it(this._cols[i].values[n])){r[n]=!1;break}}return this.s(r)},Xt.s=function(t,e){var r=P(t,this.nRow()),n=Y(e,this._names,this._dtypesVector()),i=this._names.values,o=this._cols;null!==n&&(i=vt(i,n.values),o=vt(o,n.values));var u=ut(i,"string");if(null!==r){null===n&&(o=o.slice());for(var s=0;s<o.length;s++){var a=o[s].dtype,l=vt(o[s].values,r.values);o[s]=ut(l,a)}}return mt(o,u,!1)},Xt.sMod=function(t,e,r){var n=!Ut(r)&&null!==r&&r.type===Xt.type;n||(r=Lt(r));var i=P(t,this.nRow()),o=Y(e,this._names,this._dtypesVector());if(null===o?o=Pt.seq(this.nCol()):dt(o),n){var u=null===i?this.nRow():i.size();if(u!==r.nRow()||o.size()!==r.nCol())throw new Error('"values" has the wrong dimensions for selection')}for(var s=this._cols.slice(),a=0;a<o.values.length;a++){var l=o.values[a],c=n?r._cols[a]:r;s[l]=null!==i?s[l].sMod(i,c):n?c:Pt.rep(c,this.nRow())}return mt(s,this.names(),!1)},Xt.c=function(t){var e=et(t,this._names);return this._cols[e]},Xt.cMod=function(t,e){var r=this._cols.slice(),n=et(t,this._names);return r[n]=e,mt(r,this._names)},Xt.insertCol=function(t,e,r){if(t=xt(t),r=Ut(r)?this._cols.length:r,r=Lt(r),!Number.isInteger(r))throw new Error('expected "index" to be an integer but got: '+r);var n=this._cols.slice(),i=this._names.values.slice();return n.splice(r,0,e),i.splice(r,0,t),mt(n,ut(i,"string"))},Xt.at=function(t,e){if(t=Lt(t),t=$(t,this.nRow()),e=Lt(e),Bt(e))e=$(e,this.nCol());else{if(!Ft(e)&&null!==e)throw new Error('expected "j" to be an integer or string but got: '+e);e=et(e,this._names)}return this._cols[e].values[t]},Xt.head=function(t){return Ut(t)&&(t=6),Mt(t,"n"),this.s(Pt.rng(0,t))},Xt.tail=function(t){Ut(t)&&(t=6),Mt(t,"n");var e=0>t?-t:this.nRow()-t;return this.s(Pt.rng(e,void 0))},Xt.mapCols=function(t,e){arguments.length<2&&(e=t,t=null),St(e,"func");var r=Y(t,this._names,this._dtypesVector());null===r&&(r=Pt.seq(this._cols.length));for(var n=this._names.values,i=r.values.length,o=ot(i),u=ot(i),s=0;i>s;s++){var a=r.values[s],l=this._cols[a],c=n[a];u[s]=e(l,c,a,s),o[s]=c}var h=ut(o,"string");return mt(u,h)},Xt.updateCols=function(t,e){arguments.length<2&&(e=t,t=null),St(e,"func");var r=Y(t,this._names,this._dtypesVector());null===r?r=Pt.seq(this._cols.length):dt(r);for(var n=this._names.values,i=this._cols.slice(),o=r.values.length,u=0;o>u;u++){var s=r.values[u],a=this._cols[s],l=n[s];i[s]=e(a,l,s,u)}return mt(i,this._names)},Xt.mapRowObjects=function(t,e){return St(t,"func"),this.toObjArray().map(t,e)},Xt.mapRowArrays=function(t,e){return St(t,"func"),this.toMatrix().map(t,e)},Xt.mapRowVectors=function(t,e){St(t,"func");var r=this.allDtype;if(null===r)throw new Error('cannot call "mapRowVectors" on a data frame with '+'null "allDtype" property');for(var n=this.toMatrix(),i=0;i<n.length;i++)n[i]=ut(n[i],r);return n.map(t,e)},Xt.unique=function(){if(0===this.nCol())return this;Tt(this);var t=this._getIndex().unique();return mt(t,this._names,!1)},Xt.nUnique=function(){return 0===this.nCol()?0:(Tt(this),this._getIndex().size)},Xt.duplicated=function(t){return 0===this.nCol()?ut([],"boolean"):(Tt(this),this._getIndex().duplicated(t))},Xt._getIndex=function(){return 1===this._cols.length?this._cols[0]._getIndex():(null===this._index&&(this._index=nt(this._cols)),this._index)},Xt.groupApply=function(t,e,r){if(Ut(t))throw new Error('"colSelect" must not be undefined');var n=Y(t,this._names,this._dtypesVector());if(dt(n),null===n||n.size()===this.nCol())throw new Error('"colSelect" must not select every column in the '+"data frame");if(0===n.size())throw new Error('"colSelect" must select at least 1 column');var i=this.s(null,n.ex()),o=this.s(null,n);Tt(o);var u=o._getIndex(),s=o.unique();St(e,"func"),Ut(r)||(r=Vt(r,"string"),"string"!==r.dtype&&(r=r.toDtype("string")));for(var a=s.nRow(),l=ot(a),c=-1,h=0,f=0;a>f;f++){var v=s.s(f),p=u.lookup(s._cols,f),d=i.s(p),m=e(d,v);if(!Ut(m)){var y,g;if(null===m?(y=1,g=[v,m]):m.type===Xt.type?(y=m.nCol(),g=[v,m]):m.type===Yt.type?(y=m.size(),g=[v].concat(m.values)):Array.isArray(m)?(y=m.length,g=[v].concat(m)):(y=1,g=[v,m]),c===-1){if(c=y,!Ut(r)&&y!==r.size())throw new Error('length of "colNames" must match implied number '+'of columns returned by "func"')}else if(y!==c)throw new Error("inconsistent implied column counts returned from "+'"func": '+c+", ",+y);l[h]=Pt._colCatArray(g),h++}}if(0===h)return s.s([]);l.length!==h&&(l.length=h);var b=Pt._rowCatArray(l);if(!Ut(r)){var w=b.names();w=w.sMod(Pt.rng(n.size()),r),b=b.setNames(w)}return b},Xt.transpose=function(t,e){if(0===this.nRow())return Pt.df([]);if(t=Ut(t)?null:t,null!==t&&!Ft(t))throw new Error('"preservedColName" must be a string when not null or '+"undefined");var r,n,i=this.nRow();if(Ut(e))r=this,n=pt(i);else{var o=et(e,this._names);r=this.s(null,Pt.ex(o)),n=this.c(o),"string"!==n.dtype&&(n=n.toDtype("string"))}var u,s;null!==t?(n=Pt.vCat(t,n),u=1,s=ot(i+1),s[0]=r._names):(u=0,s=ot(i));for(var a=r.nCol(),l=0;i>l;l++){for(var c=ot(a),h=0;a>h;h++)c[h]=r._cols[h].values[l];s[l+u]=c}return mt(s,n)},Xt.sort=function(t,e){if(Ut(t))throw new Error('"colSelect" must not be undefined');var r=Y(t,this._names,this._dtypesVector());null===r?r=Pt.seq(this.nCol()):dt(r);var n=this.s(null,r);if(Tt(n),e=Ut(e)?!0:e,e=Vt(e,"boolean"),It(e,"boolean"),e.isNa().any())throw new Error('"ascending" must not contain missing values');1===e.size()&&(e=Pt.rep(e,n.nCol()));var i=At(n._cols,e.values);return this.s(i)};var je=Pt.vector(["by","leftBy","rightBy","leftSuffix","rightSuffix","indicator"]);Xt.join=function(t,e,r){if(Ut(t)||null===t||t.type!==Xt.type)throw new Error('"other" must be a data frame');var n=!1,i="_x",o="_y",u=!1,s=!1;switch(e){case"inner":break;case"left":u=!0;break;case"right":s=!0;break;case"outer":u=!0,s=!0;break;default:throw new Error('"how" must be one of the following strings: '+'"inner", "left", "right", "outer"')}if(!Ut(r)){var a=Pt.vector(Object.keys(r)),l=a.s(a.isIn(je).not());if(l.size()>0)throw new Error('invalid properties found int "opts": '+l.strJoin(", "));Ut(r.indicator)||(n=r.indicator),Ut(r.leftSuffix)||(i=r.leftSuffix),Ut(r.rightSuffix)||(o=r.rightSuffix)}var c=U(this,t,r),h=c.left,f=c.right,v=this.s(null,h),p=this.s(null,h.ex()),d=t.s(null,f),m=t.s(null,f.ex());if(v.dtypes().c("dtype").contains("object")||d.dtypes().c("dtype").contains("object"))throw new Error('key columns must not have "object" dtype');if(!v.dtypes().c("dtype").equals(d.dtypes().c("dtype")))throw new Error("key columns must have matching dtypes on left "+"and right");var y,g,b=p.names().s(p.names().isIn(m.names())),w=p.names().map(function(t){return b.contains(t)?t+i:t}),_=m.names().map(function(t){return b.contains(t)?t+o:t}),x=Pt.vCat(v.names(),w,_,n?["_join"]:[]),N=d._getIndex(),E=v.nRow(),O=ot(x.size());for(g=0;g<O.length;g++)O[g]=[];if(s)for(y=ot(d.nRow()),g=0;g<y.length;g++)y[g]=!0;for(g=0;E>g;g++){var j=N.lookup(v._cols,g);if(null===j)u&&K(O,v,p,m,g,null,"leftOnly");else if("number"==typeof j)K(O,v,p,m,g,j,"both"),s&&(y[j]=!1);else for(var A=0;A<j.length;A++){var C=j[A];K(O,v,p,m,g,C,"both"),s&&(y[C]=!1)}}if(s){var M=d.s(y),z=m.s(y);for(E=M.nRow(),g=0;E>g;g++)K(O,M,p,z,null,g,"rightOnly",!0)}return mt(O,x)},Pt.rng=function(t,e,r){if(r=Ut(r)?null:r,null!==r&&"boolean"!=typeof r)throw new Error('"includeStop" must be either true, false, or null');var n=Bt(t)&&Ft(e)||Ft(t)&&Bt(e);if(n&&null===r)throw new Error('"includeStop" must be set to either true or false '+"when mixing numbers and strings for start/stop");var i=Object.create(Zt);return i._start=t,i._stop=e,i._includeStop=r,i},Zt.ex=function(){return Pt.ex(this)};var Ae=Pt.vector(Object.keys(ne));Pt.byDtype=function(t){t=Vt(t),It(t,"string"),t=t.unique();var e=t.isIn(Ae);if(!e.all()){var r=t.s(e.not()).at(0);throw new Error('invalid dtype: ""'+r+'"')}var n=Object.create($t);return n._dtypes=t,n},$t.ex=function(){return Pt.ex(this)},Pt.ex=function(t){if(Ut(t))throw new Error('"selector" must not be undefined');var e=Object.create(te);return e._selector=t,e};var Ce={INT:"INT",COL:"COL",KEY:"KEY"};Yt._resolveSelectorHelper=function(t,e){var r,n,i="number"===this.dtype,o="string"===this.dtype;switch(t.resolveMode){case Ce.INT:if(!i)throw new Error("expected number vector for integer indexing "+'but got vector with dtype: "'+this.dtype+'"');for(r=0;r<this.values.length;r++)e.push($(this.values[r],t.maxLen));break;case Ce.COL:if(i)for(r=0;r<this.values.length;r++)e.push($(this.values[r],t.maxLen));else{if(!o)throw new Error("expected number or string vector for column "+'indexing but got vector with dtype: "'+this.dtype+'"');for(r=0;r<this.values.length;r++){var u=this.values[r];n=t.index.lookupKey([u]),tt(n,u,t,e)}}break;case Ce.KEY:if(1!==t.index.arity)throw new Error("unimplemented case (TODO)");var s=t.index.initVectors[0].dtype;if(this.dtype!==s)throw new Error('expected "'+s+'" vector for key '+'lookup but got vector with dtype: "'+this.dtype+'"');var a=[this];for(r=0;r<this.values.length;r++)n=t.index.lookup(a,r),tt(n,this.values[r],t,e);break;default:throw new Error("Unrecognized RESOLVE_MODE: "+t.resolveMode)}},Zt._resolveSelectorHelper=function(t,e){var r=Z(this._start,t,!1);if(!(r>=t.maxLen)){var n=Z(this._stop,t,!0,this._includeStop);if(!(0>=n)){r=0>r?0:r,n=n>t.maxLen?t.maxLen:n;for(var i=r;n>i;i++)e.push(i)}}},$t._resolveSelectorHelper=function(t,e){if(null===t.dtypes)throw new Error("ByDtype selector can only be used for column indexing");for(var r=t.dtypes.isIn(this._dtypes).which(),n=0;n<r.values.length;n++)e.push(r.values[n])},te._resolveSelectorHelper=function(t,e){var r=[];X(this._selector,t,r);for(var n=J(ut(r,"number"),t.maxLen),i=0;i<n.values.length;i++)e.push(n.values[i])},ee.lookup=function(t,e){throw new Error('abstract "lookup" method called without concrete '+"implementation")},ee.has=function(t){for(var e=t[0].size(),r=ot(e),n=0;e>n;n++)r[n]=null!==this.lookup(t,n);return ut(r,"boolean")},ee.valueCounts=function(){for(var t=this.initVectors,e=this.arity,r=this.size,n=ot(e),i=0;e>i;i++)n[i]=ot(r);for(var o=ot(r),u=t[0].size(),s=0,a=0;u>a;a++){var l=this.lookup(t,a);if(l===a||l[0]===a){for(i=0;e>i;i++)n[i][s]=t[i].values[a];o[s]=l===a?1:l.length,s++}}var c=n.map(function(e,r){return ut(e,t[r].dtype)});return{vectors:c,counts:ut(o,"number")}},ee.unique=function(){return this.valueCounts().vectors},ee.duplicated=function(t){Ut(t)&&(t="first");var e=!1,r=!1;if("first"===t)e=!0;else if("last"===t)r=!0;else if(t!==!1)throw new Error('"keep" must be either "first", "last", or false');for(var n=this.initVectors,i=n[0].size(),o=ot(i),u=0;i>u;u++)o[u]=!1;var s=e?1:0;for(u=0;i>u;u++){var a=this.lookup(n,u);if("number"!=typeof a&&a[0]===u)for(var l=a.length,c=r?l-1:l,h=s;c>h;h++)o[a[h]]=!0}return ut(o,"boolean")};var Me={"null":"_INTERNAL_JSDATAFRAME_NULL_KEY_",undefined:"_INTERNAL_JSDATAFRAME_UNDEFINED_KEY_"};Pt._private_export.newNestedIndex=nt,re.lookup=function(t,e){for(var r=this.arity,n=this._dtypes,i=this._map,o=0;r>o;o++){var u=t[o],s=rt(u.values[e],n[o]);if(i=i[s],Ut(i))return null}return i},re.lookupKey=function(t){for(var e=this.arity,r=this._dtypes,n=this._map,i=0;e>i;i++){var o=rt(t[i],r[i]);if(n=n[o],Ut(n))return null}return n},Pt._private_export.mapNonNa=st,Pt._private_export.reduceNonNa=at,Pt._private_export.reduceUnless=lt,Pt._private_export.combineArrays=ct,Pt._private_export.inferDtype=yt,Pt._private_export.inferVectorDtype=bt,Pt._private_export.coerceToNum=wt,Pt._private_export.coerceToBool=_t,Pt._private_export.coerceToStr=xt,Pt._private_export.coerceToDate=Nt;var ze={undefined:0,"null":1,NaN:2};Pt._private_export.compare=Ot;var Se=jt(Ot);Pt._private_export.reverseComp=jt,Pt._private_export.ensureVector=Vt}); | ||
| //# sourceMappingURL=jsdataframe-min.map |
+1
-1
| { | ||
| "name": "jsdataframe", | ||
| "version": "0.1.0", | ||
| "version": "0.1.1", | ||
| "description": "a data frame library inspired by R and Python Pandas", | ||
@@ -5,0 +5,0 @@ "main": "jsdataframe.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
249845
0.07%7
16.67%3964
0.03%20
-4.76%