Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional generic types to DataFrame methods #302

Merged
merged 5 commits into from
Dec 17, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
format
  • Loading branch information
controversial committed Dec 9, 2024
commit 73deba69b3e2150d51e39f24fd723dbbaac58ce8
17 changes: 12 additions & 5 deletions polars/dataframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ export interface DataFrame<T extends Record<string, Series> = any>
limit(length?: number): DataFrame<T>;
map<ReturnT>(
// TODO: strong types for the mapping function
func: (row: any[], i: number, arr: any[][]) => ReturnT
func: (row: any[], i: number, arr: any[][]) => ReturnT,
): ReturnT[];

/**
Expand Down Expand Up @@ -1090,7 +1090,9 @@ export interface DataFrame<T extends Record<string, Series> = any>
* └─────┴─────┴─────┘
* ```
*/
nullCount(): DataFrame<{ [K in keyof T]: Series<JsToDtype<number>, K & string> }>;
nullCount(): DataFrame<{
[K in keyof T]: Series<JsToDtype<number>, K & string>;
}>;
partitionBy(
cols: string | string[],
stable?: boolean,
Expand Down Expand Up @@ -1447,7 +1449,10 @@ export interface DataFrame<T extends Record<string, Series> = any>
* ```
*/
shiftAndFill(n: number, fillValue: number): DataFrame<T>;
shiftAndFill({ n, fillValue }: { n: number; fillValue: number }): DataFrame<T>;
shiftAndFill({
n,
fillValue,
}: { n: number; fillValue: number }): DataFrame<T>;
/**
* Shrink memory usage of this DataFrame to fit the exact capacity needed to hold the data.
*/
Expand Down Expand Up @@ -1875,8 +1880,10 @@ export interface DataFrame<T extends Record<string, Series> = any>
* @param column - Series, where the name of the Series refers to the column in the DataFrame.
*/
withColumn<SeriesTypeT extends DataType, SeriesNameT extends string>(
column: Series<SeriesTypeT, SeriesNameT>
): DataFrame<Simplify<T & { [K in SeriesNameT]: Series<SeriesTypeT, SeriesNameT> }>>;
column: Series<SeriesTypeT, SeriesNameT>,
): DataFrame<
Simplify<T & { [K in SeriesNameT]: Series<SeriesTypeT, SeriesNameT> }>
>;
withColumn(column: Series | Expr): DataFrame;
withColumns(...columns: (Expr | Series)[]): DataFrame;
/**
Expand Down
Loading