dataframe-js
Version:
Immutable and functional data structure for datascientists and developpers
1,389 lines (839 loc) • 35.3 kB
Markdown
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
### Table of Contents
- [DataFrame][1]
- [toDict][2]
- [toArray][3]
- [toCollection][4]
- [toDSV][5]
- [toText][6]
- [toCSV][7]
- [toTSV][8]
- [toPSV][9]
- [toJSON][10]
- [show][11]
- [dim][12]
- [transpose][13]
- [count][14]
- [countValue][15]
- [push][16]
- [replace][17]
- [distinct][18]
- [unique][19]
- [listColumns][20]
- [select][21]
- [withColumn][22]
- [restructure][23]
- [renameAll][24]
- [rename][25]
- [castAll][26]
- [cast][27]
- [drop][28]
- [chain][29]
- [filter][30]
- [where][31]
- [find][32]
- [map][33]
- [reduce][34]
- [reduceRight][35]
- [dropDuplicates][36]
- [shuffle][37]
- [sample][38]
- [bisect][39]
- [groupBy][40]
- [sortBy][41]
- [union][42]
- [join][43]
- [innerJoin][44]
- [fullJoin][45]
- [outerJoin][46]
- [leftJoin][47]
- [rightJoin][48]
- [diff][49]
- [setDefaultModules][50]
- [fromDSV][51]
- [fromText][52]
- [fromCSV][53]
- [fromTSV][54]
- [fromPSV][55]
- [fromJSON][56]
## DataFrame
[src/dataframe.js:31-1177][57]
DataFrame data structure providing an immutable, flexible and powerfull way to manipulate data with columns and rows.
**Parameters**
- `data` **([Array][58] \| [Object][59] \| [DataFrame][60])** The data of the DataFrame.
- `columns` **[Array][58]** The DataFrame column names.
- `options` **[Object][59]** Additional options. Example: modules. (optional, default `{}`)
### toDict
[src/dataframe.js:374-381][61]
Convert DataFrame into dict / hash / object.
**Examples**
```javascript
df.toDict()
```
Returns **[Object][59]** The DataFrame converted into dict.
### toArray
[src/dataframe.js:390-394][62]
Convert DataFrame into Array of Arrays. You can also extract only one column as Array.
**Parameters**
- `columnName` **[String][63]?** Column Name to extract. By default, all columns are transformed.
**Examples**
```javascript
df.toArray()
```
Returns **[Array][58]** The DataFrame (or the column) converted into Array.
### toCollection
[src/dataframe.js:403-405][64]
Convert DataFrame into Array of dictionnaries. You can also return Rows instead of dictionnaries.
**Parameters**
- `ofRows` **[Boolean][65]?** Return a collection of Rows instead of dictionnaries.
**Examples**
```javascript
df.toCollection()
```
Returns **[Array][58]** The DataFrame converted into Array of dictionnaries (or Rows).
### toDSV
[src/dataframe.js:421-430][66]
Convert the DataFrame into a text delimiter separated values.
You can also save the file if you are using nodejs.
**Parameters**
- `sep` **[String][63]** Column separator. (optional, default `' '`)
- `header` **[Boolean][65]** Writing the header in the first line. If false, there will be no header. (optional, default `true`)
- `path` **[String][63]?** The path to save the file. /!\\ Works only on node.js, not into the browser. (optional, default `undefined`)
**Examples**
```javascript
df.toDSV()
df.toDSV(';')
df.toDSV(';', true)
// From node.js only
df.toDSV(';', true, '/my/absolute/path/dataframe.txt')
```
Returns **[String][63]** The text file in raw string.
### toText
[src/dataframe.js:446-448][67]
Convert the DataFrame into a text delimiter separated values. Alias for .toDSV.
You can also save the file if you are using nodejs.
**Parameters**
- `sep` **[String][63]** Column separator. (optional, default `' '`)
- `header` **[Boolean][65]** Writing the header in the first line. If false, there will be no header. (optional, default `true`)
- `path` **[String][63]?** The path to save the file. /!\\ Works only on node.js, not into the browser. (optional, default `undefined`)
**Examples**
```javascript
df.toText()
df.toText(';')
df.toText(';', true)
// From node.js only
df.toText(';', true, '/my/absolute/path/dataframe.txt')
```
Returns **[String][63]** The text file in raw string.
### toCSV
[src/dataframe.js:462-464][68]
Convert the DataFrame into a comma separated values string.
You can also save the file if you are using nodejs.
**Parameters**
- `header` **[Boolean][65]** Writing the header in the first line. If false, there will be no header. (optional, default `true`)
- `path` **[String][63]?** The path to save the file. /!\\ Works only on node.js, not into the browser. (optional, default `undefined`)
**Examples**
```javascript
df.toCSV()
df.toCSV(true)
// From node.js only
df.toCSV(true, '/my/absolute/path/dataframe.csv')
```
Returns **[String][63]** The csv file in raw string.
### toTSV
[src/dataframe.js:478-480][69]
Convert the DataFrame into a tab separated values string.
You can also save the file if you are using nodejs.
**Parameters**
- `header` **[Boolean][65]** Writing the header in the first line. If false, there will be no header. (optional, default `true`)
- `path` **[String][63]?** The path to save the file. /!\\ Works only on node.js, not into the browser. (optional, default `undefined`)
**Examples**
```javascript
df.toCSV()
df.toCSV(true)
// From node.js only
df.toCSV(true, '/my/absolute/path/dataframe.csv')
```
Returns **[String][63]** The csv file in raw string.
### toPSV
[src/dataframe.js:494-496][70]
Convert the DataFrame into a pipe separated values string.
You can also save the file if you are using nodejs.
**Parameters**
- `header` **[Boolean][65]** Writing the header in the first line. If false, there will be no header. (optional, default `true`)
- `path` **[String][63]?** The path to save the file. /!\\ Works only on node.js, not into the browser. (optional, default `undefined`)
**Examples**
```javascript
df.toPSV()
df.toPSV(true)
// From node.js only
df.toPSV(true, '/my/absolute/path/dataframe.csv')
```
Returns **[String][63]** The csv file in raw string.
### toJSON
[src/dataframe.js:508-516][71]
Convert the DataFrame into a json string. You can also save the file if you are using nodejs.
**Parameters**
- `asCollection` **[Boolean][65]** Writing the JSON as collection of Object. (optional, default `true`)
- `path` **[String][63]?** The path to save the file. /!\\ Works only on node.js, not into the browser. (optional, default `undefined`)
**Examples**
```javascript
df.toJSON()
// From node.js only
df.toJSON('/my/absolute/path/dataframe.json')
```
Returns **[String][63]** The json file in raw string.
### show
[src/dataframe.js:528-557][72]
Display the DataFrame as String Table. Can only return a sring instead of displaying the DataFrame.
**Parameters**
- `rows` **[Number][73]** The number of lines to display. (optional, default `10`)
- `quiet` **[Boolean][65]** Quiet mode. If true, only returns a string instead of console.log(). (optional, default `false`)
**Examples**
```javascript
df.show()
df.show(10)
const stringDF = df.show(10, true)
```
Returns **[String][63]** The DataFrame as String Table.
### dim
[src/dataframe.js:565-567][74]
Get the DataFrame dimensions.
**Examples**
```javascript
const [height, weight] = df.dim()
```
Returns **[Array][58]** The DataFrame dimensions. [height, weight]
### transpose
[src/dataframe.js:576-591][75]
Transpose a DataFrame. Rows become columns and conversely. n x p => p x n.
**Parameters**
- `tranposeColumnNames`
- `transposeColumnNames` **[Boolean][65]** An option to transpose columnNames in a rowNames column. (optional, default `false`)
**Examples**
```javascript
df.transpose()
```
Returns **ÐataFrame** A new transposed DataFrame.
### count
[src/dataframe.js:599-601][76]
Get the rows number.
**Examples**
```javascript
df.count()
```
Returns **Int** The number of DataFrame rows.
### countValue
[src/dataframe.js:612-614][77]
Get the count of a value into a column.
**Parameters**
- `valueToCount` The value to count into the selected column.
- `columnName` **[String][63]** The column to count the value. (optional, default `this.listColumns()[0]`)
**Examples**
```javascript
df.countValue(5, 'column2')
df.select('column1').countValue(5)
```
Returns **Int** The number of times the selected value appears.
### push
[src/dataframe.js:623-625][78]
Push new rows into the DataFrame.
**Parameters**
- `rows` **([Array][58] | Row)** The rows to add.
**Examples**
```javascript
df.push([1,2,3], [1,4,9])
```
Returns **[DataFrame][60]** A new DataFrame with the new rows.
### replace
[src/dataframe.js:636-644][79]
Replace a value by another in all the DataFrame or in a column.
**Parameters**
- `value` The value to replace.
- `replacement` The new value.
- `columnNames` **([String][63] \| [Array][58])** The columns to apply the replacement. (optional, default `this.listColumns()`)
**Examples**
```javascript
df.replace(undefined, 0, 'column1', 'column2')
```
Returns **[DataFrame][60]** A new DataFrame with replaced values.
### distinct
[src/dataframe.js:653-658][80]
Compute unique values into a column.
**Parameters**
- `columnName` **[String][63]** The column to distinct.
**Examples**
```javascript
df.distinct('column1')
```
Returns **[DataFrame][60]** A DataFrame containing the column with distinct values.
### unique
[src/dataframe.js:668-670][81]
Compute unique values into a column.
Alias from .distinct()
**Parameters**
- `columnName` **[String][63]** The column to distinct.
**Examples**
```javascript
df.unique('column1')
```
Returns **[DataFrame][60]** A DataFrame containing the column with distinct values.
### listColumns
[src/dataframe.js:678-680][82]
List DataFrame columns.
**Examples**
```javascript
df.listColumns()
```
Returns **[Array][58]** An Array containing DataFrame columnNames.
### select
[src/dataframe.js:689-694][83]
Select columns in the DataFrame.
**Parameters**
- `columnNames` **...[String][63]** The columns to select.
**Examples**
```javascript
df.select('column1', 'column3')
```
Returns **[DataFrame][60]** A new DataFrame containing selected columns.
### withColumn
[src/dataframe.js:705-714][84]
Add a new column or set an existing one.
**Parameters**
- `columnName` **[String][63]** The column to modify or to create.
- `func` **[Function][85]** The function to create the column. (optional, default `(row,index)=>undefined`)
**Examples**
```javascript
df.withColumn('column4', () => 2)
df.withColumn('column2', (row) => row.get('column2') * 2)
```
Returns **[DataFrame][60]** A new DataFrame containing the new or modified column.
### restructure
[src/dataframe.js:725-727][86]
Modify the structure of the DataFrame by changing columns order, creating new columns or removing some columns.
**Parameters**
- `newColumnNames` **[Array][58]** The new columns of the DataFrame.
**Examples**
```javascript
df.restructure(['column1', 'column4', 'column2', 'column3'])
df.restructure(['column1', 'column4'])
df.restructure(['column1', 'newColumn', 'column4'])
```
Returns **[DataFrame][60]** A new DataFrame with restructured columns (renamed, add or deleted).
### renameAll
[src/dataframe.js:736-741][87]
Rename each column.
**Parameters**
- `newColumnNames` **[Array][58]** The new column names of the DataFrame.
**Examples**
```javascript
df.renameAll(['column1', 'column3', 'column4'])
```
Returns **[DataFrame][60]** A new DataFrame with the new column names.
### rename
[src/dataframe.js:751-756][88]
Rename a column.
**Parameters**
- `columnName` **[String][63]** The column to rename.
- `replacement` **[String][63]** The new name for the column.
**Examples**
```javascript
df.rename('column1', 'columnRenamed')
```
Returns **[DataFrame][60]** A new DataFrame with the new column name.
### castAll
[src/dataframe.js:765-778][89]
Cast each column into a given type.
**Parameters**
- `typeFunctions` **[Array][58]** The functions used to cast columns.
**Examples**
```javascript
df.castAll([Number, String, (val) => new CustomClass(val)])
```
Returns **[DataFrame][60]** A new DataFrame with the columns having new types.
### cast
[src/dataframe.js:789-793][90]
Cast a column into a given type.
**Parameters**
- `columnName` **[String][63]** The column to cast.
- `typeFunction`
- `ObjectType` **[Function][85]** The function used to cast the column.
**Examples**
```javascript
df.cast('column1', Number)
df.cast('column1', (val) => new MyCustomClass(val))
```
Returns **[DataFrame][60]** A new DataFrame with the column having a new type.
### drop
[src/dataframe.js:802-807][91]
Remove a single column.
**Parameters**
- `columnName` **[String][63]** The column to drop.
**Examples**
```javascript
df.drop('column2')
```
Returns **[DataFrame][60]** A new DataFrame without the dropped column.
### chain
[src/dataframe.js:822-827][92]
Chain maps and filters functions on DataFrame by optimizing their executions.
If a function returns boolean, it's a filter. Else it's a map.
It can be 10 - 100 x faster than standard chains of .map() and .filter().
**Parameters**
- `funcs` **...[Function][85]** Functions to apply on the DataFrame rows taking the row as parameter.
**Examples**
```javascript
df.chain(
row => row.get('column1') > 3, // filter
row => row.set('column1', 3), // map
row => row.get('column2') === '5' // filter
)
```
Returns **[DataFrame][60]** A new DataFrame with modified rows.
### filter
[src/dataframe.js:837-853][93]
Filter DataFrame rows.
**Parameters**
- `condition` **([Function][85] \| [Object][59])** A filter function or a column/value object.
**Examples**
```javascript
df.filter(row => row.get('column1') >= 3)
df.filter({'column2': 5, 'column1': 3}))
```
Returns **[DataFrame][60]** A new filtered DataFrame.
### where
[src/dataframe.js:864-866][94]
Filter DataFrame rows.
Alias of .filter()
**Parameters**
- `condition` **([Function][85] \| [Object][59])** A filter function or a column/value object.
**Examples**
```javascript
df.where(row => row.get('column1') >= 3)
df.where({'column2': 5, 'column1': 3}))
```
Returns **[DataFrame][60]** A new filtered DataFrame.
### find
[src/dataframe.js:876-878][95]
Find a row (the first met) based on a condition.
**Parameters**
- `condition` **([Function][85] \| [Object][59])** A filter function or a column/value object.
**Examples**
```javascript
df.find(row => row.get('column1') === 3)
df.find({'column1': 3})
```
Returns **Row** The targeted Row.
### map
[src/dataframe.js:887-892][96]
Map on DataFrame rows. /!\\ Prefer to use .chain().
**Parameters**
- `func` **[Function][85]** A function to apply on each row taking the row as parameter.
**Examples**
```javascript
df.map(row => row.set('column1', row.get('column1') * 2))
```
Returns **[DataFrame][60]** A new DataFrame with modified rows.
### reduce
[src/dataframe.js:906-910][97]
Reduce DataFrame into a value.
**Parameters**
- `func` **[Function][85]** The reduce function taking 2 parameters, previous and next.
- `init` The initial value of the reducer.
**Examples**
```javascript
df.reduce((p, n) => n.get('column1') + p, 0)
df2.reduce((p, n) => (
n.set('column1', p.get('column1') + n.get('column1'))
.set('column2', p.get('column2') + n.get('column2'))
))
```
Returns **any** A reduced value.
### reduceRight
[src/dataframe.js:920-924][98]
Reduce DataFrame into a value, starting from the last row (see .reduce()).
**Parameters**
- `func` **[Function][85]** The reduce function taking 2 parameters, previous and next.
- `init` The initial value of the reducer.
**Examples**
```javascript
df.reduceRight((p, n) => p > n ? p : n, 0)
```
Returns **any** A reduced value.
### dropDuplicates
[src/dataframe.js:933-939][99]
Return a DataFrame without duplicated columns.
**Parameters**
- `columnNames` **...[String][63]** The columns used to check unicity of rows. If omitted, unicity is checked on all columns.
**Examples**
```javascript
df.dropDuplicates('id', 'name')
```
Returns **[DataFrame][60]** A DataFrame without duplicated rows.
### shuffle
[src/dataframe.js:947-957][100]
Return a shuffled DataFrame rows.
**Examples**
```javascript
df.shuffle()
```
Returns **[DataFrame][60]** A shuffled DataFrame.
### sample
[src/dataframe.js:966-982][101]
Return a random sample of rows.
**Parameters**
- `percentage` **[Number][73]** A percentage of the orignal DataFrame giving the sample size.
**Examples**
```javascript
df.sample(0.3)
```
Returns **[DataFrame][60]** A sample DataFrame
### bisect
[src/dataframe.js:991-1010][102]
Randomly split a DataFrame into 2 DataFrames.
**Parameters**
- `percentage` **[Number][73]** A percentage of the orignal DataFrame giving the first DataFrame size. The second takes the rest.
**Examples**
```javascript
const [30DF, 70DF] = df.bisect(0.3)
```
Returns **[Array][58]** An Array containing the two DataFrames. First, the X% DataFrame then the rest DataFrame.
### groupBy
[src/dataframe.js:1023-1025][103]
Group DataFrame rows by columns giving a GroupedDataFrame object. See its doc for more examples.
**Parameters**
- `columnNames` **...[String][63]** The columns used for the groupBy.
**Examples**
```javascript
df.groupBy('column1')
df.groupBy('column1', 'column2')
df.groupBy('column1', 'column2').listGroups()
df.groupBy('column1', 'column2').show()
df.groupBy('column1', 'column2').aggregate((group) => group.count())
```
Returns **GroupedDataFrame** A GroupedDataFrame object.
### sortBy
[src/dataframe.js:1037-1056][104]
Sort DataFrame rows based on column values. The row should contains only one variable type. Columns are sorted left-to-right.
**Parameters**
- `columnNames` **([String][63] \| [Array][58]<[string][63]>)** The columns giving order.
- `reverse` **[Boolean][65]** Reverse mode. Reverse the order if true. (optional, default `false`)
**Examples**
```javascript
df.sortBy('id')
df.sortBy(['id1', 'id2'])
df.sortBy(['id1'], true)
```
Returns **[DataFrame][60]** An ordered DataFrame.
### union
[src/dataframe.js:1065-1078][105]
Concat two DataFrames.
**Parameters**
- `dfToUnion` **[DataFrame][60]** The DataFrame to concat.
**Examples**
```javascript
df.union(df2)
```
Returns **[DataFrame][60]** A new concatenated DataFrame resulting of the union.
### join
[src/dataframe.js:1089-1098][106]
Join two DataFrames.
**Parameters**
- `dfToJoin` **[DataFrame][60]** The DataFrame to join.
- `columnNames` **([String][63] \| [Array][58])** The selected columns for the join.
- `how` **[String][63]** The join mode. Can be: full, inner, outer, left, right. (optional, default `'inner'`)
**Examples**
```javascript
df.join(df2, 'column1', 'full')
```
Returns **[DataFrame][60]** The joined DataFrame.
### innerJoin
[src/dataframe.js:1110-1112][107]
Join two DataFrames with inner mode.
**Parameters**
- `dfToJoin` **[DataFrame][60]** The DataFrame to join.
- `columnNames` **([String][63] \| [Array][58])** The selected columns for the join.
**Examples**
```javascript
df.innerJoin(df2, 'id')
df.join(df2, 'id')
df.join(df2, 'id', 'inner')
```
Returns **[DataFrame][60]** The joined DataFrame.
### fullJoin
[src/dataframe.js:1123-1125][108]
Join two DataFrames with full mode.
**Parameters**
- `dfToJoin` **[DataFrame][60]** The DataFrame to join.
- `columnNames` **([String][63] \| [Array][58])** The selected columns for the join.
**Examples**
```javascript
df.fullJoin(df2, 'id')
df.join(df2, 'id', 'full')
```
Returns **[DataFrame][60]** The joined DataFrame.
### outerJoin
[src/dataframe.js:1136-1138][109]
Join two DataFrames with outer mode.
**Parameters**
- `dfToJoin` **[DataFrame][60]** The DataFrame to join.
- `columnNames` **([String][63] \| [Array][58])** The selected columns for the join.
**Examples**
```javascript
df2.outerJoin(df2, 'id')
df2.join(df2, 'id', 'outer')
```
Returns **[DataFrame][60]** The joined DataFrame.
### leftJoin
[src/dataframe.js:1149-1151][110]
Join two DataFrames with left mode.
**Parameters**
- `dfToJoin` **[DataFrame][60]** The DataFrame to join.
- `columnNames` **([String][63] \| [Array][58])** The selected columns for the join.
**Examples**
```javascript
df.leftJoin(df2, 'id')
df.join(df2, 'id', 'left')
```
Returns **[DataFrame][60]** The joined DataFrame.
### rightJoin
[src/dataframe.js:1162-1164][111]
Join two DataFrames with right mode.
**Parameters**
- `dfToJoin` **[DataFrame][60]** The DataFrame to join.
- `columnNames` **([String][63] \| [Array][58])** The selected columns for the join.
**Examples**
```javascript
df.rightJoin(df2, 'id')
df.join(df2, 'id', 'right')
```
Returns **[DataFrame][60]** The joined DataFrame.
### diff
[src/dataframe.js:1174-1176][112]
Find the differences between two DataFrames (reverse of join).
**Parameters**
- `dfToDiff` **[DataFrame][60]** The DataFrame to diff.
- `columnNames` **([String][63] \| [Array][58])** The selected columns for the diff.
**Examples**
```javascript
df2.diff(df2, 'id')
```
Returns **[DataFrame][60]** The differences DataFrame.
### setDefaultModules
[src/dataframe.js:40-42][113]
Set the default modules used in DataFrame instances.
**Parameters**
- `defaultModules` **...[Object][59]** DataFrame modules used by default.
**Examples**
```javascript
DataFrame.setDefaultModules(SQL, Stat)
```
### fromDSV
[src/dataframe.js:57-76][114]
Create a DataFrame from a delimiter separated values text file. It returns a Promise.
**Parameters**
- `pathOrFile` **([String][63] | File)** A path to the file (url or local) or a browser File object.
- `sep` **[String][63]** The separator used to parse the file. (optional, default `";"`)
- `header` **[Boolean][65]** A boolean indicating if the text has a header or not. (optional, default `true`)
**Examples**
```javascript
DataFrame.fromDSV('http://myurl/myfile.txt').then(df => df.show())
// In browser Only
DataFrame.fromDSV(myFile).then(df => df.show())
// From node.js only Only
DataFrame.fromDSV('/my/absolue/path/myfile.txt').then(df => df.show())
DataFrame.fromDSV('/my/absolue/path/myfile.txt', ';', true).then(df => df.show())
```
### fromText
[src/dataframe.js:91-93][115]
Create a DataFrame from a delimiter separated values text file. It returns a Promise. Alias of DataFrame.fromDSV.
**Parameters**
- `pathOrFile` **([String][63] | File)** A path to the file (url or local) or a browser File object.
- `sep` **[String][63]** The separator used to parse the file. (optional, default `";"`)
- `header` **[Boolean][65]** A boolean indicating if the text has a header or not. (optional, default `true`)
**Examples**
```javascript
DataFrame.fromText('http://myurl/myfile.txt').then(df => df.show())
// In browser Only
DataFrame.fromText(myFile).then(df => df.show())
// From node.js only Only
DataFrame.fromText('/my/absolue/path/myfile.txt').then(df => df.show())
DataFrame.fromText('/my/absolue/path/myfile.txt', ';', true).then(df => df.show())
```
### fromCSV
[src/dataframe.js:107-109][116]
Create a DataFrame from a comma separated values file. It returns a Promise.
**Parameters**
- `pathOrFile` **([String][63] | File)** A path to the file (url or local) or a browser File object.
- `header` **[Boolean][65]** A boolean indicating if the csv has a header or not. (optional, default `true`)
**Examples**
```javascript
DataFrame.fromCSV('http://myurl/myfile.csv').then(df => df.show())
// For browser only
DataFrame.fromCSV(myFile).then(df => df.show())
// From node.js only
DataFrame.fromCSV('/my/absolue/path/myfile.csv').then(df => df.show())
DataFrame.fromCSV('/my/absolue/path/myfile.csv', true).then(df => df.show())
```
### fromTSV
[src/dataframe.js:123-125][117]
Create a DataFrame from a tab separated values file. It returns a Promise.
**Parameters**
- `pathOrFile` **([String][63] | File)** A path to the file (url or local) or a browser File object.
- `header` **[Boolean][65]** A boolean indicating if the tsv has a header or not. (optional, default `true`)
**Examples**
```javascript
DataFrame.fromTSV('http://myurl/myfile.tsv').then(df => df.show())
// For browser only
DataFrame.fromTSV(myFile).then(df => df.show())
// From node.js only
DataFrame.fromTSV('/my/absolue/path/myfile.tsv').then(df => df.show())
DataFrame.fromTSV('/my/absolue/path/myfile.tsv', true).then(df => df.show())
```
### fromPSV
[src/dataframe.js:139-141][118]
Create a DataFrame from a pipe separated values file. It returns a Promise.
**Parameters**
- `pathOrFile` **([String][63] | File)** A path to the file (url or local) or a browser File object.
- `header` **[Boolean][65]** A boolean indicating if the psv has a header or not. (optional, default `true`)
**Examples**
```javascript
DataFrame.fromPSV('http://myurl/myfile.psv').then(df => df.show())
// For browser only
DataFrame.fromPSV(myFile).then(df => df.show())
// From node.js only
DataFrame.fromPSV('/my/absolue/path/myfile.psv').then(df => df.show())
DataFrame.fromPSV('/my/absolue/path/myfile.psv', true).then(df => df.show())
```
### fromJSON
[src/dataframe.js:153-164][119]
Create a DataFrame from a JSON file. It returns a Promise.
**Parameters**
- `pathOrFile` **([String][63] | File)** A path to the file (url or local) or a browser File object.
**Examples**
```javascript
DataFrame.fromJSON('http://myurl/myfile.json').then(df => df.show())
// For browser only
DataFrame.fromJSON(myFile).then(df => df.show())
// From node.js only
DataFrame.fromJSON('/my/absolute/path/myfile.json').then(df => df.show())
```
[1]: #dataframe
[2]: #todict
[3]: #toarray
[4]: #tocollection
[5]: #todsv
[6]: #totext
[7]: #tocsv
[8]: #totsv
[9]: #topsv
[10]: #tojson
[11]: #show
[12]: #dim
[13]: #transpose
[14]: #count
[15]: #countvalue
[16]: #push
[17]: #replace
[18]: #distinct
[19]: #unique
[20]: #listcolumns
[21]: #select
[22]: #withcolumn
[23]: #restructure
[24]: #renameall
[25]: #rename
[26]: #castall
[27]: #cast
[28]: #drop
[29]: #chain
[30]: #filter
[31]: #where
[32]: #find
[33]: #map
[34]: #reduce
[35]: #reduceright
[36]: #dropduplicates
[37]: #shuffle
[38]: #sample
[39]: #bisect
[40]: #groupby
[41]: #sortby
[42]: #union
[43]: #join
[44]: #innerjoin
[45]: #fulljoin
[46]: #outerjoin
[47]: #leftjoin
[48]: #rightjoin
[49]: #diff
[50]: #setdefaultmodules
[51]: #fromdsv
[52]: #fromtext
[53]: #fromcsv
[54]: #fromtsv
[55]: #frompsv
[56]: #fromjson
[57]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L31-L1177 "Source code on GitHub"
[58]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
[59]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
[60]: #dataframe
[61]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L374-L381 "Source code on GitHub"
[62]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L390-L394 "Source code on GitHub"
[63]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[64]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L403-L405 "Source code on GitHub"
[65]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
[66]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L421-L430 "Source code on GitHub"
[67]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L446-L448 "Source code on GitHub"
[68]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L462-L464 "Source code on GitHub"
[69]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L478-L480 "Source code on GitHub"
[70]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L494-L496 "Source code on GitHub"
[71]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L508-L516 "Source code on GitHub"
[72]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L528-L557 "Source code on GitHub"
[73]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
[74]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L565-L567 "Source code on GitHub"
[75]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L576-L591 "Source code on GitHub"
[76]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L599-L601 "Source code on GitHub"
[77]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L612-L614 "Source code on GitHub"
[78]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L623-L625 "Source code on GitHub"
[79]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L636-L644 "Source code on GitHub"
[80]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L653-L658 "Source code on GitHub"
[81]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L668-L670 "Source code on GitHub"
[82]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L678-L680 "Source code on GitHub"
[83]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L689-L694 "Source code on GitHub"
[84]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L705-L714 "Source code on GitHub"
[85]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function
[86]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L725-L727 "Source code on GitHub"
[87]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L736-L741 "Source code on GitHub"
[88]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L751-L756 "Source code on GitHub"
[89]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L765-L778 "Source code on GitHub"
[90]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L789-L793 "Source code on GitHub"
[91]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L802-L807 "Source code on GitHub"
[92]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L822-L827 "Source code on GitHub"
[93]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L837-L853 "Source code on GitHub"
[94]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L864-L866 "Source code on GitHub"
[95]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L876-L878 "Source code on GitHub"
[96]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L887-L892 "Source code on GitHub"
[97]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L906-L910 "Source code on GitHub"
[98]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L920-L924 "Source code on GitHub"
[99]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L933-L939 "Source code on GitHub"
[100]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L947-L957 "Source code on GitHub"
[101]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L966-L982 "Source code on GitHub"
[102]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L991-L1010 "Source code on GitHub"
[103]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L1023-L1025 "Source code on GitHub"
[104]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L1037-L1056 "Source code on GitHub"
[105]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L1065-L1078 "Source code on GitHub"
[106]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L1089-L1098 "Source code on GitHub"
[107]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L1110-L1112 "Source code on GitHub"
[108]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L1123-L1125 "Source code on GitHub"
[109]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L1136-L1138 "Source code on GitHub"
[110]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L1149-L1151 "Source code on GitHub"
[111]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L1162-L1164 "Source code on GitHub"
[112]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L1174-L1176 "Source code on GitHub"
[113]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L40-L42 "Source code on GitHub"
[114]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L57-L76 "Source code on GitHub"
[115]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L91-L93 "Source code on GitHub"
[116]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L107-L109 "Source code on GitHub"
[117]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L123-L125 "Source code on GitHub"
[118]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L139-L141 "Source code on GitHub"
[119]: https://github.com/Gmousse/dataframe-js/blob/cef738e8a8e82e94515dfc49f015f842a8c410f2/src/dataframe.js#L153-L164 "Source code on GitHub"