You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 17, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+76-7Lines changed: 76 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
# dataframe-js
2
-
**v0.1.0**
2
+
**v0.2.0**
3
3
4
4
## Presentation
5
5
@@ -10,6 +10,8 @@ A DataFrame is simply built on two concepts:
10
10
-**Rows** providing ways to modify or filter your data.
11
11
12
12
````javascript
13
+
constdf=newDataFrame(rawData, columns)
14
+
df.show()
13
15
// DataFrame example
14
16
| column1 | column2 | column3 |<--- Columns
15
17
------------------------------------
@@ -19,11 +21,11 @@ A DataFrame is simply built on two concepts:
19
21
|undefined|6|undefined|
20
22
````
21
23
22
-
**DataFrame is immutable** (lazy, for performance purposes). Then, each modification on DataFrame will return a new DataFrame decreasing bug risks and making your data more secure.
24
+
**DataFrame is immutable** (lazy, for performance purposes). Then, each modification on DataFrame will return a new DataFrame decreasing side effects and making your data more secure.
23
25
24
26
**DataFrame is easy to use** with a simple API (closed to Spark or SQL) designed to manipulate data faster and easier than ever.
25
27
26
-
**DataFrame is flexible** because you can switch from or to arrays and dictionnaries (hash, object) when you want.
28
+
**DataFrame is flexible** because you can create DataFrames from multiple data format (array, object) and you can export your DataFrames into these (array, object, csv, json...).
27
29
28
30
**DataFrame is modulable** because you can use additional modules (Stat and Matrix by default) or create your own.
29
31
@@ -44,11 +46,72 @@ dataframe-js contains a **principal core (DataFrame and Row)** and **two default
44
46
To use dataframe-js, simply import the library. Then you can use DataFrame, Row or other Core components.
45
47
46
48
```javascript
47
-
import { DataFrame } from'dataframe-js';
49
+
import { DataFrame, Row } from'dataframe-js';
50
+
```
51
+
52
+
To create a DataFrame, you have to passe your data and your column names. You can use different data structures as below:
48
53
54
+
```javascript
49
55
constdf=newDataFrame(myData, myColumns);
56
+
57
+
constdfFromObjectOfArrays=newDataFrame({
58
+
column1: [3, 6, 8], //<------ A column
59
+
column2: [3, 4, 5, 6],
60
+
}, ['column1', 'column2']);
61
+
62
+
constdfFromArrayOfArrays=newDataFrame([
63
+
[1, 6, 9, 10, 12], // <------- A row
64
+
[1, 2],
65
+
[6, 6, 9, 8, 9, 12],
66
+
], ['c1', 'c2', 'c3', 'c4', 'c5', 'c6']);
67
+
68
+
constdfFromArrayOfObjects=newDataFrame([
69
+
{c1:1, c2:6}, // <--- A row
70
+
{c4:1, c3:2}
71
+
], ['c1', 'c2', 'c3', 'c4']);
72
+
```
73
+
74
+
If you don't pass column names, they will be infered from your data but **it's slower**:
75
+
76
+
```javascript
77
+
// here you don't pass column names
78
+
constdfFromObjectOfArrays=newDataFrame({
79
+
column1: [3, 6, 8], //<------ A column
80
+
column2: [3, 4, 5, 6],
81
+
});
82
+
83
+
console.log(dfFromObjectOfArrays.listColumns())
84
+
// ['column1', 'column2']
85
+
86
+
constdfFromArrayOfArrays=newDataFrame([
87
+
[1, 6, 9, 10, 12], // <------- A row
88
+
[1, 2],
89
+
[6, 6, 9, 8, 9, 12],
90
+
]);
91
+
92
+
console.log(dfFromArrayOfArrays.listColumns())
93
+
// ['0', '1', '2', '3', '4', '5']
94
+
95
+
96
+
constdfFromArrayOfObjects=newDataFrame([
97
+
{c1:1, c2:6}, // <--- A row
98
+
{c4:1, c3:2}
99
+
]);
100
+
101
+
console.log(dfFromArrayOfObjects.listColumns())
102
+
// ['c1', 'c2', 'c3', 'c4']
50
103
```
51
104
105
+
Of course, you can do the reverse by exporting your DataFrame in another format by using:
When you realize some operations on a DataFrame (or on a Row), it is never mutated. Indeed, when you modify a DataFrame (even if nothing change) you create a new instance of DataFrame. It's a bit slower but you avoid side effects.
53
116
54
117
Examples:
@@ -77,7 +140,9 @@ console.log(
77
140
78
141
```
79
142
80
-
#### List of available methods:
143
+
For more informations you can find the API below.
144
+
145
+
#### List of available methods and their examples:
0 commit comments