Skip to content

Commit

Permalink
fix(dataframe): warn type of replaceAtIdx
Browse files Browse the repository at this point in the history
  • Loading branch information
scarf005 committed Nov 18, 2024
1 parent fef1d43 commit d802fa5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion __tests__/dataframe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ describe("dataframe", () => {
expect(actual.columns).toEqual(["foo_new", "bar_new", "ham_new"]);
});
test("replaceAtIdx", () => {
const actual = pl.DataFrame({
const actual: pl.DataFrame = pl.DataFrame({
foo: [1, 2, 3],
bar: [6, 7, 8],
ham: ["a", "b", "c"],
Expand Down
5 changes: 4 additions & 1 deletion polars/dataframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1191,12 +1191,15 @@ export interface DataFrame<T extends Record<string, Series> = any>
rename(mapping: Record<string, string>): DataFrame;
/**
* Replace a column at an index location.
*
* @warning typescript cannot encode type mutation,
* so the type of the DataFrame will be incorrect. cast the type of dataframe manually.
* ___
* @param index - Column index
* @param newColumn - New column to insert
* @example
* ```
* > const df = pl.DataFrame({
* > const df: pl.DataFrame = pl.DataFrame({
* ... "foo": [1, 2, 3],
* ... "bar": [6, 7, 8],
* ... "ham": ['a', 'b', 'c']
Expand Down

0 comments on commit d802fa5

Please sign in to comment.