12
12
* limitations under the License.
13
13
* ==========================================================================
14
14
*/
15
- import { toCSVBrowser , toExcelBrowser , toJSONBrowser } from "../io/browser" ;
16
- import { toCSVNode , toExcelNode , toJSONNode } from "../io/node" ;
17
15
import dummyEncode from "../transformers/encoders/dummy.encoder" ;
18
16
import { variance , std , median , mode , mean } from 'mathjs' ;
19
17
import tensorflow from '../shared/tensorflowlib'
@@ -32,12 +30,6 @@ import {
32
30
ArrayType2D ,
33
31
DataFrameInterface ,
34
32
BaseDataOptionType ,
35
- CsvOutputOptionsBrowser ,
36
- ExcelOutputOptionsBrowser ,
37
- JsonOutputOptionsBrowser ,
38
- CsvOutputOptionsNode ,
39
- ExcelOutputOptionsNode ,
40
- JsonOutputOptionsNode
41
33
} from "../shared/types" ;
42
34
43
35
const utils = new Utils ( ) ;
@@ -3383,157 +3375,6 @@ export default class DataFrame extends NDframe implements DataFrameInterface {
3383
3375
}
3384
3376
}
3385
3377
3386
- /**
3387
- * Converts a DataFrame to CSV.
3388
- * @param options Configuration object. Supports the following options:
3389
- * - `filePath`: Local file path to write the CSV file. If not specified, the CSV will be returned as a string. Option is only available in NodeJS.
3390
- * - `fileName`: Name of the CSV file. Defaults to `data.csv`. Option is only available in Browser.
3391
- * - `download`: If true, the CSV will be downloaded. Defaults to false. Option is only available in Browser.
3392
- * - `header`: Boolean indicating whether to include a header row in the CSV file.
3393
- * - `sep`: Character to be used as a separator in the CSV file.
3394
- *
3395
- * @example
3396
- * ```
3397
- * const df = new DataFrame([[1, 2], [3, 4]], { columns: ['A', 'B']})
3398
- * const csv = df.toCSV()
3399
- * console.log(csv)
3400
- * //output
3401
- * "A","B"
3402
- * 1,2
3403
- * 3,4
3404
- * ```
3405
- *
3406
- * @example
3407
- * ```
3408
- * const df = new DataFrame([[1, 2], [3, 4]], { columns: ['A', 'B']})
3409
- * const csv = df.toCSV({ header: false })
3410
- * console.log(csv)
3411
- * //output
3412
- * 1,2
3413
- * 3,4
3414
- * ```
3415
- *
3416
- * @example
3417
- * ```
3418
- * const df = new DataFrame([[1, 2], [3, 4]], { columns: ['A', 'B']})
3419
- * const csv = df.toCSV({ sep: ';' })
3420
- * console.log(csv)
3421
- * //output
3422
- * "A";"B"
3423
- * 1;2
3424
- * 3;4
3425
- * ```
3426
- *
3427
- * @example
3428
- * ```
3429
- * const df = new DataFrame([[1, 2], [3, 4]], { columns: ['A', 'B']})
3430
- * df.toCSV({ filePath: './data.csv' }) //write to local file in NodeJS
3431
- * ```
3432
- *
3433
- * @example
3434
- * ```
3435
- * const df = new DataFrame([[1, 2], [3, 4]], { columns: ['A', 'B']})
3436
- * df.toCSV({ fileName: 'data.csv', download: true }) //Downloads file in Browser
3437
- * ```
3438
- *
3439
- */
3440
- toCSV ( options ?: CsvOutputOptionsBrowser | CsvOutputOptionsNode ) : string
3441
- toCSV ( options ?: CsvOutputOptionsBrowser | CsvOutputOptionsNode ) : string | void {
3442
- if ( utils . isBrowserEnv ( ) ) {
3443
- return toCSVBrowser ( this , options as CsvOutputOptionsBrowser )
3444
- } else {
3445
- return toCSVNode ( this , options as CsvOutputOptionsNode )
3446
- }
3447
- }
3448
-
3449
- /**
3450
- * Converts a DataFrame to JSON.
3451
- * @param options Configuration object. Supported options:
3452
- * - `filePath`: The file path to write the JSON to. If not specified, the JSON object is returned. Option is only available in NodeJS.
3453
- * - `fileName`: The name of the JSON file. Defaults to `data.json`. Option is only available in Browser.
3454
- * - `download`: If true, the JSON will be downloaded. Defaults to false. Option is only available in Browser.
3455
- * - `format`: The format of the JSON. Supported values are `'column'` and `'row'`. Defaults to `'column'`.
3456
- *
3457
- * @example
3458
- * ```
3459
- * const df = new DataFrame([[1, 2], [3, 4]], { columns: ['A', 'B']})
3460
- * const json = df.toJSON()
3461
- * ```
3462
- *
3463
- * @example
3464
- * ```
3465
- * const df = new DataFrame([[1, 2], [3, 4]], { columns: ['A', 'B']})
3466
- * const json = df.toJSON({ format: 'row' })
3467
- * console.log(json)
3468
- * //output
3469
- * [{"A":1,"B":2},{"A":3,"B":4}]
3470
- * ```
3471
- *
3472
- * @example
3473
- * ```
3474
- * const df = new DataFrame([[1, 2], [3, 4]], { columns: ['A', 'B']})
3475
- * const json = df.toJSON({ format: "column" })
3476
- * console.log(json)
3477
- * //output
3478
- * {"A":[1,3],"B":[2,4]}
3479
- * ```
3480
- *
3481
- * @example
3482
- * ```
3483
- * const df = new DataFrame([[1, 2], [3, 4]], { columns: ['A', 'B']})
3484
- * df.toJSON({ filePath: './data.json' }) // downloads to local file system as data.json in NodeJS
3485
- * ```
3486
- *
3487
- * @example
3488
- * ```
3489
- * const df = new DataFrame([[1, 2], [3, 4]], { columns: ['A', 'B']})
3490
- * df.toJSON({ fileName: 'data.json', download: true }) // downloads file browser
3491
- * ```
3492
- */
3493
- toJSON ( options ?: JsonOutputOptionsBrowser | JsonOutputOptionsNode ) : object
3494
- toJSON ( options ?: JsonOutputOptionsBrowser | JsonOutputOptionsNode ) : object | void {
3495
- if ( utils . isBrowserEnv ( ) ) {
3496
- return toJSONBrowser ( this , options as JsonOutputOptionsBrowser )
3497
- } else {
3498
- return toJSONNode ( this , options as JsonOutputOptionsNode )
3499
- }
3500
- }
3501
-
3502
-
3503
- /**
3504
- * Converts a DataFrame to Excel file format.
3505
- * @param options Configuration object. Supported options:
3506
- * - `sheetName`: The sheet name to be written to. Defaults to `'Sheet1'`.
3507
- * - `filePath`: The filePath to be written to. Defaults to `'./output.xlsx'`. Option is only available in NodeJs
3508
- * - `fileName`: The fileName to be written to. Defaults to `'output.xlsx'`. Option is only available in Browser
3509
- *
3510
- * @example
3511
- * ```
3512
- * const df = new DataFrame([[1, 2], [3, 4]], { columns: ['A', 'B']})
3513
- * df.toExcel({ filePath: './output.xlsx' }) // writes to local file system as output.xlsx in NodeJS
3514
- * ```
3515
- *
3516
- * @example
3517
- * ```
3518
- * const df = new DataFrame([[1, 2], [3, 4]], { columns: ['A', 'B']})
3519
- * df.toExcel({ fileName: 'output.xlsx', download: true }) // downloads file browser
3520
- * ```
3521
- *
3522
- * @example
3523
- * ```
3524
- * const df = new DataFrame([[1, 2], [3, 4]], { columns: ['A', 'B']})
3525
- * df.toExcel({ sheetName: 'Sheet2' }) // writes to Sheet2 in Excel
3526
- * ```
3527
- *
3528
- */
3529
- toExcel ( options ?: ExcelOutputOptionsBrowser | ExcelOutputOptionsNode ) : void {
3530
- if ( utils . isBrowserEnv ( ) ) {
3531
- toExcelBrowser ( this , options as ExcelOutputOptionsBrowser )
3532
- } else {
3533
- return toExcelNode ( this , options as ExcelOutputOptionsNode )
3534
- }
3535
- }
3536
-
3537
3378
/**
3538
3379
* Access a single value for a row/column pair by integer position.
3539
3380
* Similar to {@link iloc}, in that both provide integer-based lookups.
0 commit comments