Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/danfojs-base/core/generic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,15 +285,15 @@ export default class NDframe implements NDframeInterface {

this.$index = index
} else {
this.$index = utils.range(0, this.shape[0] - 1) //generate index
this.$index = utils.erange(0, this.shape[0]) //generate index
}
}

/**
* Internal function to reset the index of the NDFrame using a range of indices.
*/
$resetIndex(): void {
this.$index = utils.range(0, this.shape[0] - 1)
this.$index = utils.erange(0, this.shape[0])
}

/**
Expand Down Expand Up @@ -333,7 +333,7 @@ export default class NDframe implements NDframeInterface {

this.$columns = columns
} else {
this.$columns = (utils.range(0, this.shape[1] - 1)).map((val) => `${val}`) //generate columns
this.$columns = (utils.erange(0, this.shape[1])).map((val) => `${val}`) //generate columns
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions src/danfojs-base/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,19 @@ export default class Utils {
return arr;
}

/**
* Generates an array of integers between specified range with exclusive end
* @param start The starting number.
* @param end The exclusive end number.
*/
erange(start: number, end: number): Array<number> {
const arr = [];
for (let i = start; i < end; i++) {
arr.push(i);
}
return arr;
}

/**
* Checks if object has the specified key
* @param obj The object to check.
Expand Down