Skip to content

Commit 1b7a42f

Browse files
authored
Removing deprecated methods (#305)
Removing deprecated methods
1 parent 2c0e091 commit 1b7a42f

File tree

9 files changed

+10
-148
lines changed

9 files changed

+10
-148
lines changed

__tests__/dataframe.test.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -655,14 +655,18 @@ describe("dataframe", () => {
655655
.median();
656656
expect(actual.row(0)).toEqual([2, 7, null]);
657657
});
658-
test("melt", () => {
658+
test("unpivot", () => {
659659
const df = pl.DataFrame({
660660
id: [1],
661661
asset_key_1: ["123"],
662662
asset_key_2: ["456"],
663663
asset_key_3: ["abc"],
664664
});
665-
const actual = df.melt("id", ["asset_key_1", "asset_key_2", "asset_key_3"]);
665+
const actual = df.unpivot("id", [
666+
"asset_key_1",
667+
"asset_key_2",
668+
"asset_key_3",
669+
]);
666670
const expected = pl.DataFrame({
667671
id: [1, 1, 1],
668672
variable: ["asset_key_1", "asset_key_2", "asset_key_3"],

__tests__/series.test.ts

-1
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,6 @@ describe("series", () => {
330330
${numSeries()} | ${"isNotNaN"} | ${[]}
331331
${numSeries()} | ${"isNumeric"} | ${[]}
332332
${numSeries()} | ${"isUnique"} | ${[]}
333-
${numSeries()} | ${"isUtf8"} | ${[]}
334333
${numSeries()} | ${"kurtosis"} | ${[]}
335334
${numSeries()} | ${"kurtosis"} | ${[{ fisher: true, bias: true }]}
336335
${numSeries()} | ${"kurtosis"} | ${[{ bias: false }]}

polars/dataframe.ts

-38
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,6 @@ export interface DataFrame<T extends Record<string, Series> = any>
308308
* ```
309309
*/
310310
describe(): DataFrame;
311-
/** @deprecated *since 0.4.0* use {@link unique} */
312-
distinct(maintainOrder?, subset?, keep?): DataFrame;
313311
/**
314312
* __Remove column from DataFrame and return as new.__
315313
* ___
@@ -1001,11 +999,6 @@ export interface DataFrame<T extends Record<string, Series> = any>
1001999
* ```
10021000
*/
10031001
median(): DataFrame<T>;
1004-
/**
1005-
* Unpivot a DataFrame from wide to long format.
1006-
* @deprecated *since 0.13.0* use {@link unpivot}
1007-
*/
1008-
melt(idVars: ColumnSelection, valueVars: ColumnSelection): DataFrame;
10091002
/**
10101003
* Unpivot a DataFrame from wide to long format.
10111004
* ___
@@ -1604,11 +1597,6 @@ export interface DataFrame<T extends Record<string, Series> = any>
16041597
* ```
16051598
*/
16061599
tail(length?: number): DataFrame<T>;
1607-
/**
1608-
* @deprecated *since 0.4.0* use {@link writeCSV}
1609-
* @category Deprecated
1610-
*/
1611-
toCSV(destOrOptions?, options?);
16121600
/**
16131601
* Converts dataframe object into row oriented javascript objects
16141602
* @example
@@ -1653,17 +1641,6 @@ export interface DataFrame<T extends Record<string, Series> = any>
16531641
* @category IO
16541642
*/
16551643
toObject(): { [K in keyof T]: DTypeToJs<T[K]["dtype"] | null>[] };
1656-
1657-
/**
1658-
* @deprecated *since 0.4.0* use {@link writeIPC}
1659-
* @category IO Deprecated
1660-
*/
1661-
toIPC(destination?, options?);
1662-
/**
1663-
* @deprecated *since 0.4.0* use {@link writeParquet}
1664-
* @category IO Deprecated
1665-
*/
1666-
toParquet(destination?, options?);
16671644
toSeries(index?: number): T[keyof T];
16681645
toString(): string;
16691646
/**
@@ -2166,9 +2143,6 @@ export const _DataFrame = (_df: any): DataFrame => {
21662143
}
21672144
return wrap("dropNulls");
21682145
},
2169-
distinct(opts: any = false, subset?, keep = "first") {
2170-
return this.unique(opts, subset);
2171-
},
21722146
unique(opts: any = false, subset?, keep = "first") {
21732147
const defaultOptions = {
21742148
maintainOrder: false,
@@ -2352,9 +2326,6 @@ export const _DataFrame = (_df: any): DataFrame => {
23522326
median() {
23532327
return this.lazy().median().collectSync();
23542328
},
2355-
melt(ids, values) {
2356-
return wrap("unpivot", columnOrColumns(ids), columnOrColumns(values));
2357-
},
23582329
unpivot(ids, values) {
23592330
return wrap("unpivot", columnOrColumns(ids), columnOrColumns(values));
23602331
},
@@ -2546,9 +2517,6 @@ export const _DataFrame = (_df: any): DataFrame => {
25462517
serialize(format) {
25472518
return _df.serialize(format);
25482519
},
2549-
toCSV(...args) {
2550-
return this.writeCSV(...args);
2551-
},
25522520
writeCSV(dest?, options = {}) {
25532521
if (dest instanceof Writable || typeof dest === "string") {
25542522
return _df.writeCsv(dest, options) as any;
@@ -2632,9 +2600,6 @@ export const _DataFrame = (_df: any): DataFrame => {
26322600

26332601
return Buffer.concat(buffers);
26342602
},
2635-
toParquet(dest?, options?) {
2636-
return this.writeParquet(dest, options);
2637-
},
26382603
writeParquet(dest?, options = { compression: "uncompressed" }) {
26392604
if (dest instanceof Writable || typeof dest === "string") {
26402605
return _df.writeParquet(dest, options.compression) as any;
@@ -2669,9 +2634,6 @@ export const _DataFrame = (_df: any): DataFrame => {
26692634

26702635
return Buffer.concat(buffers);
26712636
},
2672-
toIPC(dest?, options?) {
2673-
return this.writeIPC(dest, options);
2674-
},
26752637
writeIPC(dest?, options = { compression: "uncompressed" }) {
26762638
if (dest instanceof Writable || typeof dest === "string") {
26772639
return _df.writeIpc(dest, options.compression) as any;

polars/groupby.ts

+2-11
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,6 @@ export interface GroupBy {
4444
*/
4545
agg(...columns: Expr[]): DataFrame;
4646
agg(columns: Record<string, keyof Expr | (keyof Expr)[]>): DataFrame;
47-
/**
48-
* Count the number of values in each group.
49-
* @deprecated @since 0.10.0 @use {@link len}
50-
*/
51-
count(): DataFrame;
5247
/**
5348
* Return the number of rows in each group.
5449
*/
@@ -164,9 +159,8 @@ export interface GroupBy {
164159

165160
export type PivotOps = Pick<
166161
GroupBy,
167-
"count" | "first" | "max" | "mean" | "median" | "min" | "sum"
162+
"len" | "first" | "max" | "mean" | "median" | "min" | "sum"
168163
> & { [inspect](): string };
169-
170164
/** @ignore */
171165
export function _GroupBy(df: any, by: string[], maintainOrder = false) {
172166
const customInspect = () =>
@@ -212,9 +206,6 @@ export function _GroupBy(df: any, by: string[], maintainOrder = false) {
212206
agg,
213207
pivot,
214208
aggList: () => agg(exclude(by as any)),
215-
count() {
216-
return _DataFrame(df.groupby([by].flat(), by, "count"));
217-
},
218209
len() {
219210
return _DataFrame(df.groupby([by].flat(), by, "count"));
220211
},
@@ -254,7 +245,7 @@ function PivotOps(
254245
min: pivot("min"),
255246
max: pivot("max"),
256247
mean: pivot("mean"),
257-
count: pivot("count"),
248+
len: pivot("len"),
258249
median: pivot("median"),
259250
};
260251
}

polars/lazy/dataframe.ts

-28
Original file line numberDiff line numberDiff line change
@@ -74,24 +74,6 @@ export interface LazyDataFrame extends Serialize, GroupByOps<LazyGroupBy> {
7474
drop(name: string): LazyDataFrame;
7575
drop(names: string[]): LazyDataFrame;
7676
drop(name: string, ...names: string[]): LazyDataFrame;
77-
/**
78-
* Drop duplicate rows from this DataFrame.
79-
* Note that this fails if there is a column of type `List` in the DataFrame.
80-
* @param maintainOrder
81-
* @param subset - subset to drop duplicates for
82-
* @param keep "first" | "last"
83-
* @deprecated @since 0.4.0 @use {@link unique}
84-
*/
85-
distinct(
86-
maintainOrder?: boolean,
87-
subset?: ColumnSelection,
88-
keep?: "first" | "last",
89-
): LazyDataFrame;
90-
distinct(opts: {
91-
maintainOrder?: boolean;
92-
subset?: ColumnSelection;
93-
keep?: "first" | "last";
94-
}): LazyDataFrame;
9577
/**
9678
* Drop rows with null values from this DataFrame.
9779
* This method only drops nulls row-wise if any single value of the row is null.
@@ -370,9 +352,7 @@ export interface LazyDataFrame extends Serialize, GroupByOps<LazyGroupBy> {
370352
median(): LazyDataFrame;
371353
/**
372354
* @see {@link DataFrame.unpivot}
373-
* @deprecated *since 0.13.0* use {@link unpivot}
374355
*/
375-
melt(idVars: ColumnSelection, valueVars: ColumnSelection): LazyDataFrame;
376356
unpivot(idVars: ColumnSelection, valueVars: ColumnSelection): LazyDataFrame;
377357
/**
378358
* @see {@link DataFrame.min}
@@ -687,9 +667,6 @@ export const _LazyDataFrame = (_ldf: any): LazyDataFrame => {
687667
drop(...cols) {
688668
return _LazyDataFrame(_ldf.dropColumns(cols.flat(2)));
689669
},
690-
distinct(...args: any[]) {
691-
return _LazyDataFrame((_ldf.unique as any)(...args));
692-
},
693670
unique(opts: any = false, subset?, keep = "first") {
694671
const defaultOptions = {
695672
maintainOrder: false,
@@ -993,11 +970,6 @@ export const _LazyDataFrame = (_ldf: any): LazyDataFrame => {
993970
median() {
994971
return _LazyDataFrame(_ldf.median());
995972
},
996-
melt(ids, values) {
997-
return _LazyDataFrame(
998-
_ldf.unpivot(columnOrColumnsStrict(ids), columnOrColumnsStrict(values)),
999-
);
1000-
},
1001973
unpivot(ids, values) {
1002974
return _LazyDataFrame(
1003975
_ldf.unpivot(columnOrColumnsStrict(ids), columnOrColumnsStrict(values)),

polars/lazy/expr/string.ts

-28
Original file line numberDiff line numberDiff line change
@@ -113,31 +113,6 @@ export interface StringNamespace extends StringFunctions<Expr> {
113113
* Throw errors if encounter invalid JSON strings.
114114
* @params Not implemented ATM
115115
* @returns DF with struct
116-
* @deprecated @since 0.8.4 @use {@link jsonDecode}
117-
* @example
118-
119-
* >>> df = pl.DataFrame( {json: ['{"a":1, "b": true}', null, '{"a":2, "b": false}']} )
120-
* >>> df.select(pl.col("json").str.jsonExtract())
121-
* shape: (3, 1)
122-
* ┌─────────────┐
123-
* │ json │
124-
* │ --- │
125-
* │ struct[2] │
126-
* ╞═════════════╡
127-
* │ {1,true} │
128-
* │ {null,null} │
129-
* │ {2,false} │
130-
* └─────────────┘
131-
* See Also
132-
* ----------
133-
* jsonPathMatch : Extract the first match of json string with provided JSONPath expression.
134-
*/
135-
jsonExtract(dtype?: DataType, inferSchemaLength?: number): Expr;
136-
/**
137-
* Parse string values as JSON.
138-
* Throw errors if encounter invalid JSON strings.
139-
* @params Not implemented ATM
140-
* @returns DF with struct
141116
* @example
142117
143118
* >>> df = pl.DataFrame( {json: ['{"a":1, "b": true}', null, '{"a":2, "b": false}']} )
@@ -369,9 +344,6 @@ export const ExprStringFunctions = (_expr: any): StringNamespace => {
369344
extract(pat: any, groupIndex: number) {
370345
return wrap("strExtract", exprToLitOrExpr(pat, true)._expr, groupIndex);
371346
},
372-
jsonExtract(dtype?: DataType, inferSchemaLength?: number) {
373-
return wrap("strJsonDecode", dtype, inferSchemaLength);
374-
},
375347
jsonDecode(dtype?: DataType, inferSchemaLength?: number) {
376348
return wrap("strJsonDecode", dtype, inferSchemaLength);
377349
},

polars/series/index.ts

-19
Original file line numberDiff line numberDiff line change
@@ -526,12 +526,6 @@ export interface Series<T extends DataType = any, Name extends string = string>
526526
* ```
527527
*/
528528
isUnique(): Series;
529-
/**
530-
* Checks if this Series datatype is a Utf8.
531-
* @deprecated *since 0.8.4*
532-
* @see Use `Series.dtype.equals(pl.String)` instead.
533-
*/
534-
isUtf8(): boolean;
535529
/**
536530
* Checks if this Series datatype is a String.
537531
*/
@@ -805,13 +799,6 @@ export interface Series<T extends DataType = any, Name extends string = string>
805799
nullEqual?: boolean,
806800
strict?: boolean,
807801
): boolean;
808-
/**
809-
* __Set masked values__
810-
* @param filter Boolean mask
811-
* @param value value to replace masked values with
812-
* @deprecated @since 0.8.4 @use {@link scatter}
813-
*/
814-
setAtIdx(indices: number[] | Series, value: any): void;
815802
/**
816803
* __Set masked values__
817804
* @param filter Boolean mask
@@ -1526,9 +1513,6 @@ export function _Series(_s: any): Series {
15261513
isString() {
15271514
return this.dtype.equals(DataType.String);
15281515
},
1529-
isUtf8() {
1530-
return this.dtype.equals(DataType.Utf8);
1531-
},
15321516
kurtosis(fisher: any = true, bias = true) {
15331517
if (typeof fisher === "boolean") {
15341518
return _s.kurtosis(fisher, bias);
@@ -1715,9 +1699,6 @@ export function _Series(_s: any): Series {
17151699
clip(...args) {
17161700
return expr_op("clip", ...args);
17171701
},
1718-
setAtIdx(indices, value) {
1719-
_s.scatter(indices, value);
1720-
},
17211702
scatter(indices, value) {
17221703
indices = Series.isSeries(indices)
17231704
? indices.cast(DataType.UInt32)

polars/series/string.ts

-19
Original file line numberDiff line numberDiff line change
@@ -94,22 +94,6 @@ export interface StringNamespace extends StringFunctions<Series> {
9494
* ```
9595
*/
9696
extract(pattern: any, groupIndex: number): Series;
97-
/***
98-
* Parse string values as JSON.
99-
* @returns Utf8 array. Contain null if original value is null or the `jsonPath` return nothing.
100-
* @deprecated @since 0.8.4 @use {@link jsonDecode}
101-
* @example
102-
* s = pl.Series("json", ['{"a":1, "b": true}', null, '{"a":2, "b": false}']);
103-
* s.str.jsonExtract().as("json");
104-
* shape: (3,)
105-
* Series: 'json' [struct[2]]
106-
* [
107-
* {1,true}
108-
* {null,null}
109-
* {2,false}
110-
* ]
111-
*/
112-
jsonExtract(dtype?: DataType, inferSchemaLength?: number): Series;
11397
/***
11498
* Parse string values as JSON.
11599
* @returns Utf8 array. Contain null if original value is null or the `jsonPath` return nothing.
@@ -322,9 +306,6 @@ export const SeriesStringFunctions = (_s: any): StringNamespace => {
322306
.select(col(s.name).str.extract(pat, groupIndex).as(s.name))
323307
.getColumn(s.name);
324308
},
325-
jsonExtract(dtype?: DataType, inferSchemaLength?: number) {
326-
return wrap("strJsonDecode", dtype, inferSchemaLength);
327-
},
328309
jsonDecode(dtype?: DataType, inferSchemaLength?: number) {
329310
return wrap("strJsonDecode", dtype, inferSchemaLength);
330311
},

src/conversion.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -830,8 +830,8 @@ impl FromNapiValue for Wrap<CsvWriterOptions> {
830830
let obj = Object::from_napi_value(env, napi_val)?;
831831
let include_bom = obj.get::<_, bool>("includeBom")?.unwrap_or(false);
832832
let include_header = obj.get::<_, bool>("includeHeader")?.unwrap_or(true);
833-
let batch_size =
834-
NonZero::new(obj.get::<_, i64>("batchSize")?.unwrap_or(1024) as usize).ok_or_else(|| napi::Error::from_reason("Invalid batch size"))?;
833+
let batch_size = NonZero::new(obj.get::<_, i64>("batchSize")?.unwrap_or(1024) as usize)
834+
.ok_or_else(|| napi::Error::from_reason("Invalid batch size"))?;
835835
let maintain_order = obj.get::<_, bool>("maintainOrder")?.unwrap_or(true);
836836
let date_format = obj.get::<_, String>("dateFormat")?;
837837
let time_format = obj.get::<_, String>("timeFormat")?;

0 commit comments

Comments
 (0)