Skip to content

Commit a6e2cf4

Browse files
authored
Merge pull request #347 from Devwulf/dev
Added type to DataFrame.rename mapper
2 parents 6e115cb + 8087a3f commit a6e2cf4

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/danfojs-base/core/frame.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2754,14 +2754,18 @@ export default class DataFrame extends NDframe implements DataFrameInterface {
27542754
*
27552755
*/
27562756
rename(
2757-
mapper: any,
2757+
mapper: {
2758+
[index: string | number]: string | number
2759+
},
27582760
options?: {
27592761
axis?: 0 | 1
27602762
inplace?: boolean
27612763
}
27622764
): DataFrame
2763-
rename(
2764-
mapper: any,
2765+
rename(
2766+
mapper: {
2767+
[index: string | number]: string | number
2768+
},
27652769
options?: {
27662770
axis?: 0 | 1
27672771
inplace?: boolean
@@ -2777,8 +2781,9 @@ export default class DataFrame extends NDframe implements DataFrameInterface {
27772781
const colsAdded: string[] = [];
27782782
const newColumns = this.columns.map(col => {
27792783
if (mapper[col] !== undefined) {
2780-
colsAdded.push(mapper[col]);
2781-
return mapper[col]
2784+
const newCol = `${mapper[col]}`;
2785+
colsAdded.push(newCol);
2786+
return newCol;
27822787
} else {
27832788
return col
27842789
}

0 commit comments

Comments
 (0)