Skip to content

Commit ef3a3b4

Browse files
committed
Update type defs
1 parent 1bed8ee commit ef3a3b4

File tree

5 files changed

+35
-11
lines changed

5 files changed

+35
-11
lines changed

src/danfojs-base/core/frame.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
* limitations under the License.
1313
* ==========================================================================
1414
*/
15-
import { ArrayType1D, ArrayType2D, DataFrameInterface, BaseDataOptionType } from "../shared/types";
15+
import {
16+
ArrayType1D,
17+
ArrayType2D,
18+
DataFrameInterface,
19+
BaseDataOptionType
20+
} from "../shared/types";
1621
import dummyEncode from "../transformers/encoders/dummy.encoder"
1722
import { variance, std, median, mode, mean } from 'mathjs';
1823
import { DATA_TYPES } from '../shared/defaults'
@@ -38,7 +43,6 @@ const utils = new Utils();
3843
* @param options.dtypes Array of data types for each the column. If not specified, dtypes are/is inferred.
3944
* @param options.config General configuration object for extending or setting NDframe behavior.
4045
*/
41-
/* @ts-ignore */ //COMMENT OUT WHEN METHODS HAVE BEEN IMPLEMENTED
4246
export default class DataFrame extends NDframe implements DataFrameInterface {
4347
[key: string]: any
4448
constructor(data: any, options: BaseDataOptionType = {}) {
@@ -1376,7 +1380,7 @@ export default class DataFrame extends NDframe implements DataFrameInterface {
13761380
} else {
13771381
let columns = [...this.columns]
13781382
columns.splice(atIndex, 0, column)
1379-
1383+
13801384
const df = new DataFrame(newData, {
13811385
index: [...this.index],
13821386
columns: columns,

src/danfojs-base/core/series.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export default class Series extends NDframe implements SeriesInterface {
8686
* ``.iloc`` will raise ``IndexError`` if a requested indexer is
8787
* out-of-bounds.
8888
*/
89-
iloc(rows: Array<string | number | boolean>) {
89+
iloc(rows: Array<string | number | boolean>): Series {
9090
return _iloc({ ndFrame: this, rows }) as Series
9191
}
9292

@@ -111,7 +111,7 @@ export default class Series extends NDframe implements SeriesInterface {
111111
* - A ``callable`` function with one argument (the calling Series or
112112
* DataFrame) and that returns valid output for indexing (one of the above)
113113
*/
114-
loc(rows: Array<string | number | boolean>) {
114+
loc(rows: Array<string | number | boolean>): Series {
115115
return _loc({ ndFrame: this, rows }) as Series
116116
}
117117

src/danfojs-browser/src/types.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
1-
import { ParseConfig } from 'papaparse';
2-
import { Config, Layout } from "plotly.js-dist-min"
1+
/**
2+
* @license
3+
* Copyright 2021, JsData. All rights reserved.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
* ==========================================================================
14+
*/
315

16+
/**
17+
* This file contains all type definitions unique to danfojs-browser version.
18+
*/
19+
20+
import { ParseConfig } from 'papaparse';
21+
import { Config, Layout } from "plotly.js-dist-min"
422

523
interface CustomConfig extends Config {
624
x: string

src/danfojs-node/src/core/frame.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* ==========================================================================
1414
*/
1515
import { toCSV, toExcel, toJSON } from "../io";
16-
import { CsvOutputOptionsNode } from "types";
16+
import { CsvOutputOptionsNode, ExcelOutputOptionsNode, JsonOutputOptionsNode } from "types";
1717
import BaseDataFrame from "../../../danfojs-base/core/frame"
1818
import { BaseDataOptionType } from "../../../danfojs-base/shared/types";
1919

@@ -63,8 +63,8 @@ export default class DataFrame extends BaseDataFrame {
6363
* }
6464
* ```
6565
*/
66-
toJSON(options?: { format?: "row" | "column", filePath?: string }): object
67-
toJSON(options?: { format?: "row" | "column", filePath?: string }): object | void {
66+
toJSON(options?: JsonOutputOptionsNode): object
67+
toJSON(options?: JsonOutputOptionsNode): object | void {
6868
return toJSON(this, options);
6969
}
7070

@@ -75,7 +75,7 @@ export default class DataFrame extends BaseDataFrame {
7575
* - `sheetName`: The sheet name to be written to. Defaults to `'Sheet1'`.
7676
* - `filePath`: The filePath to be written to. Defaults to `'./output.xlsx'`.
7777
*/
78-
toExcel(options?: { filePath?: string, sheetName?: string }): void {
78+
toExcel(options?: ExcelOutputOptionsNode): void {
7979
return toExcel(this, options);
8080
}
8181
}

src/danfojs-node/src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
import { ParseConfig } from 'papaparse';
22
export interface CsvInputOptions extends ParseConfig { }
33
export type CsvOutputOptionsNode = { filePath?: string, sep?: string, header?: boolean }
4+
export type JsonOutputOptionsNode = { format?: "row" | "column", filePath?: string }
5+
export type ExcelOutputOptionsNode = { filePath?: string, sheetName?: string }

0 commit comments

Comments
 (0)