MCPcopy Index your code
hub / github.com/javascriptdata/danfojs / constructor

Method constructor

src/danfojs-base/core/generic.ts:62–100  ·  view source on GitHub ↗
({ data, index, columns, dtypes, config, isSeries }: NdframeInputDataType)

Source from the content-addressed store, hash-verified

60 protected $config: Configs
61
62 constructor({ data, index, columns, dtypes, config, isSeries }: NdframeInputDataType) {
63 this.$isSeries = isSeries
64 if (config) {
65 this.$config = new Configs({ ...BASE_CONFIG, ...config });
66 } else {
67 this.$config = new Configs(BASE_CONFIG);
68 }
69
70 if (data instanceof tensorflow.Tensor) {
71 data = data.arraySync();
72 }
73
74 if (data === undefined || (Array.isArray(data) && data.length === 0)) {
75 if (columns === undefined) columns = [];
76 if (dtypes === undefined) dtypes = [];
77 if (columns.length === 0 && dtypes.length !== 0) ErrorThrower.throwDtypeWithoutColumnError();
78 this.loadArrayIntoNdframe({ data: [], index: [], columns: columns, dtypes: dtypes });
79 } else if (utils.is1DArray(data)) {
80 this.loadArrayIntoNdframe({ data, index, columns, dtypes });
81 } else {
82 if (Array.isArray(data) && utils.isObject(data[0])) {
83 this.loadObjectIntoNdframe({ data, type: 1, index, columns, dtypes });
84
85 } else if (utils.isObject(data)) {
86 this.loadObjectIntoNdframe({ data, type: 2, index, columns, dtypes });
87
88 } else if (
89 Array.isArray((data)[0]) ||
90 utils.isNumber((data)[0]) ||
91 utils.isString((data)[0])
92 ) {
93 this.loadArrayIntoNdframe({ data, index, columns, dtypes });
94 } else if (Array.isArray(data) && data.length > 0 && utils.isDate(data[0])) {
95 this.loadArrayIntoNdframe({ data, index, columns, dtypes });
96 } else {
97 throw new Error("File format not supported!");
98 }
99 }
100 }
101
102 /**
103 * Internal function to load array of data into NDFrame

Callers

nothing calls this directly

Calls 7

loadArrayIntoNdframeMethod · 0.95
loadObjectIntoNdframeMethod · 0.95
is1DArrayMethod · 0.80
isObjectMethod · 0.80
isNumberMethod · 0.80
isStringMethod · 0.80
isDateMethod · 0.80

Tested by

no test coverage detected