MCPcopy Index your code
hub / github.com/javascriptdata/danfojs / $setIndex

Method $setIndex

src/danfojs-base/core/generic.ts:276–290  ·  view source on GitHub ↗

* Internal function to set the index of the NDFrame with the specified * array of indices. Performs all necessary checks to ensure that the * index is valid.

(index: Array<string | number> | undefined)

Source from the content-addressed store, hash-verified

274 * index is valid.
275 */
276 $setIndex(index: Array<string | number> | undefined): void {
277 if (index) {
278
279 if (this.$data.length != 0 && index.length != this.shape[0]) {
280 ErrorThrower.throwIndexLengthError(this, index)
281 }
282 if (Array.from(new Set(index)).length !== this.shape[0]) {
283 ErrorThrower.throwIndexDuplicateError()
284 }
285
286 this.$index = index
287 } else {
288 this.$index = utils.range(0, this.shape[0] - 1) //generate index
289 }
290 }
291
292 /**
293 * Internal function to reset the index of the NDFrame using a range of indices.

Callers 1

loadArrayIntoNdframeMethod · 0.95

Calls 1

rangeMethod · 0.45

Tested by

no test coverage detected