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'
@@ -22,7 +20,6 @@ import { _genericMathOp } from "./math.ops";
22
20
import Groupby from '../aggregators/groupby' ;
23
21
import ErrorThrower from "../shared/errors"
24
22
import { _iloc , _loc } from "./indexing" ;
25
- import { PlotlyLib } from "../plotting" ;
26
23
import Utils from "../shared/utils"
27
24
import NDframe from "./generic" ;
28
25
import { table } from "table" ;
@@ -32,12 +29,6 @@ import {
32
29
ArrayType2D ,
33
30
DataFrameInterface ,
34
31
BaseDataOptionType ,
35
- CsvOutputOptionsBrowser ,
36
- ExcelOutputOptionsBrowser ,
37
- JsonOutputOptionsBrowser ,
38
- CsvOutputOptionsNode ,
39
- ExcelOutputOptionsNode ,
40
- JsonOutputOptionsNode
41
32
} from "../shared/types" ;
42
33
43
34
const utils = new Utils ( ) ;
@@ -3368,172 +3359,6 @@ export default class DataFrame extends NDframe implements DataFrameInterface {
3368
3359
3369
3360
}
3370
3361
3371
- /**
3372
- * Exposes functions for creating charts from a DataFrame.
3373
- * Charts are created using the Plotly.js library, so all Plotly's configuration parameters are available.
3374
- * @param divId name of the HTML Div to render the chart in.
3375
- */
3376
- plot ( divId : string ) {
3377
- //TODO: Add support for check plot library to use. So we can support other plot library like d3, vega, etc
3378
- if ( utils . isBrowserEnv ( ) ) {
3379
- const plt = new PlotlyLib ( this , divId ) ;
3380
- return plt ;
3381
- } else {
3382
- throw new Error ( "Not supported in NodeJS" ) ;
3383
- }
3384
- }
3385
-
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
3362
/**
3538
3363
* Access a single value for a row/column pair by integer position.
3539
3364
* Similar to {@link iloc}, in that both provide integer-based lookups.
0 commit comments