| 40 | * @param options.config General configuration object for extending or setting NDframe behavior. |
| 41 | */ |
| 42 | export default class DataFrame extends BaseDataFrame implements ExtendedDataFrameInterface { |
| 43 | [key: string]: any |
| 44 | constructor(data?: any, options: BaseDataOptionType = {}) { |
| 45 | super(data, options) |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Converts a DataFrame to CSV. |
| 50 | * @param options Configuration object. Supports the following options: |
| 51 | * - `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. |
| 52 | * - `fileName`: Name of the CSV file. Defaults to `data.csv`. Option is only available in Browser. |
| 53 | * - `download`: If true, the CSV will be downloaded. Defaults to false. Option is only available in Browser. |
| 54 | * - `header`: Boolean indicating whether to include a header row in the CSV file. |
| 55 | * - `sep`: Character to be used as a separator in the CSV file. |
| 56 | * |
| 57 | * @example |
| 58 | * ``` |
| 59 | * const df = new DataFrame([[1, 2], [3, 4]], { columns: ['A', 'B']}) |
| 60 | * const csv = df.toCSV() |
| 61 | * console.log(csv) |
| 62 | * //output |
| 63 | * "A","B" |
| 64 | * 1,2 |
| 65 | * 3,4 |
| 66 | * ``` |
| 67 | * |
| 68 | * @example |
| 69 | * ``` |
| 70 | * const df = new DataFrame([[1, 2], [3, 4]], { columns: ['A', 'B']}) |
| 71 | * const csv = df.toCSV({ header: false }) |
| 72 | * console.log(csv) |
| 73 | * //output |
| 74 | * 1,2 |
| 75 | * 3,4 |
| 76 | * ``` |
| 77 | * |
| 78 | * @example |
| 79 | * ``` |
| 80 | * const df = new DataFrame([[1, 2], [3, 4]], { columns: ['A', 'B']}) |
| 81 | * const csv = df.toCSV({ sep: ';' }) |
| 82 | * console.log(csv) |
| 83 | * //output |
| 84 | * "A";"B" |
| 85 | * 1;2 |
| 86 | * 3;4 |
| 87 | * ``` |
| 88 | * |
| 89 | * @example |
| 90 | * ``` |
| 91 | * const df = new DataFrame([[1, 2], [3, 4]], { columns: ['A', 'B']}) |
| 92 | * df.toCSV({ filePath: './data.csv' }) //write to local file in NodeJS |
| 93 | * ``` |
| 94 | * |
| 95 | * @example |
| 96 | * ``` |
| 97 | * const df = new DataFrame([[1, 2], [3, 4]], { columns: ['A', 'B']}) |
| 98 | * df.toCSV({ fileName: 'data.csv', download: true }) //Downloads file in Browser |
| 99 | * ``` |
nothing calls this directly
no outgoing calls
no test coverage detected