Skip to content

Commit b0e3c3a

Browse files
committed
Merge branch 'danfo/typescript' into dev
2 parents 48364ef + b5c6699 commit b0e3c3a

File tree

138 files changed

+69863
-43
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+69863
-43
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
.editorconfig
2-
node_modules
2+
node_modules
3+
test/fixtures/*
4+
test/samples/*
5+
*.xlsx

README.md

Lines changed: 58 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -46,79 +46,94 @@ easy and intuitive. It is heavily inspired by [Pandas](https://pandas.pydata.org
4646
- Robust data preprocessing functions like [OneHotEncoders](https://danfo.jsdata.org/api-reference/general-functions/danfo.onehotencoder), [LabelEncoders](https://danfo.jsdata.org/api-reference/general-functions/danfo.labelencoder), and scalers like [StandardScaler](https://danfo.jsdata.org/api-reference/general-functions/danfo.standardscaler) and [MinMaxScaler](https://danfo.jsdata.org/api-reference/general-functions/danfo.minmaxscaler) are supported on DataFrame and Series
4747

4848

49+
## Installation
50+
There are three ways to install and use Danfo.js in your application
51+
* For Nodejs applications, you can install the [__danfojs-node__]() version via package managers like yarn and/or npm:
4952

50-
To use Danfo.js via script tags, copy and paste the CDN below to the body of your HTML file
53+
```bash
54+
npm install danfojs-node
55+
56+
or
57+
58+
yarn add danfojs-node
59+
```
60+
For client-side applications built with frameworks like React, Vue, Next.js, etc, you can install the [__danfojs__]() version:
61+
62+
```bash
63+
npm install danfojs
64+
65+
or
66+
67+
yarn add danfojs
68+
```
69+
70+
For use directly in HTML files, you can add the latest script tag from [JsDelivr](https://www.jsdelivr.com/package/npm/danfojs) to your HTML file:
71+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/bundle.min.js"></script>
5172

5273
```html
53-
<script src="https://cdn.jsdelivr.net/npm/danfojs@0.3.4/lib/bundle.min.js"></script>
74+
<script src="https://cdn.jsdelivr.net/npm/danfojs@1.0.0/lib/bundle.min.js"></script>
5475
```
5576
See all available versions [here](https://www.jsdelivr.com/package/npm/danfojs)
5677

5778
### Example Usage in the Browser
5879

59-
> See the example below in [Code Sandbox](https://codepen.io/risingodegua/pen/bGwPGMG)
80+
> Run in [Code Sandbox](https://codepen.io/risingodegua/pen/bGwPGMG)
6081
6182
```html
6283

6384
<!DOCTYPE html>
6485
<html lang="en">
65-
<head>
66-
<meta charset="UTF-8">
67-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
68-
<script src="https://cdn.plot.ly/plotly-2.2.0.min.js"></script>
69-
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/bundle.min.js"></script>
86+
<head>
87+
<meta charset="UTF-8" />
88+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
89+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/bundle.min.js"></script>
7090

7191
<title>Document</title>
72-
</head>
73-
74-
<body>
92+
</head>
7593

94+
<body>
7695
<div id="div1"></div>
7796
<div id="div2"></div>
7897
<div id="div3"></div>
7998

8099
<script>
81100
82-
dfd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv")
83-
.then(df => {
101+
dfd.readCSV("https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv")
102+
.then(df => {
84103
85-
df['AAPL.Open'].plot("div1").box() //makes a box plot
104+
df['AAPL.Open'].plot("div1").box() //makes a box plot
86105
87-
df.plot("div2").table() //display csv as table
106+
df.plot("div2").table() //display csv as table
88107
89-
new_df = df.set_index({ column: "Date" }) //resets the index to Date column
90-
new_df.plot("div3").line({ columns: ["AAPL.Open", "AAPL.High"] }) //makes a timeseries plot
91-
92-
}).catch(err => {
93-
console.log(err);
94-
})
108+
new_df = df.setIndex({ column: "Date", drop: true }); //resets the index to Date column
109+
new_df.head().print() //
110+
new_df.plot("div3").line({
111+
config: {
112+
columns: ["AAPL.Open", "AAPL.High"]
113+
}
114+
}) //makes a timeseries plot
95115
116+
}).catch(err => {
117+
console.log(err);
118+
})
96119
</script>
97-
98-
</body>
99-
120+
</body>
100121
</html>
122+
101123
```
102124

103125
Output in Browser:
104126

105127
![](assets/browser-out.gif)
106128

107-
## How to install
108-
Danfo.js is hosted on NPM, and can installed via package managers like npm and yarn
109-
110-
```sh
111-
npm install danfojs-node
112-
```
113-
114129
### Example usage in Nodejs
115130

116131
```javascript
117132

118133
const dfd = require("danfojs-node")
119134

120135
const file_url = "https://web.stanford.edu/class/archive/cs/cs109/cs109.1166/stuff/titanic.csv"
121-
dfd.read_csv(file_url)
136+
dfd.readCSV(file_url)
122137
.then(df => {
123138
//prints the first five columns
124139
df.head().print()
@@ -144,41 +159,44 @@ dfd.read_csv(file_url)
144159
df_drop.print()
145160

146161

162+
//select columns by dtypes
163+
let str_cols = df_drop.selectDtypes(["string"])
164+
let num_cols = df_drop.selectDtypes(["int32", "float32"])
165+
str_cols.print()
166+
num_cols.print()
167+
147168
//select columns by dtypes
148169
let str_cols = df_drop.select_dtypes(["string"])
149170
let num_cols = df_drop.select_dtypes(["int32", "float32"])
150171
str_cols.print()
151172
num_cols.print()
152173

153-
154174
//add new column to Dataframe
155175

156176
let new_vals = df['Fare'].round(1)
157-
df_drop.addColumn({ column: "fare_round", values: new_vals, inplace: true })
177+
df_drop.addColumn("fare_round", new_vals, { inplace: true })
158178
df_drop.print()
159179

160180
df_drop['fare_round'].round(2).print(5)
161181

162182
//prints the number of occurence each value in the column
163-
df_drop['Survived'].value_counts().print()
183+
df_drop['Survived'].valueCounts().print()
164184

165185
//print the last ten elementa of a DataFrame
166186
df_drop.tail(10).print()
167187

168188
//prints the number of missing values in a DataFrame
169-
df_drop.isna().sum().print()
189+
df_drop.isNa().sum().print()
170190

171191
}).catch(err => {
172192
console.log(err);
173193
})
174194

195+
175196
```
176197
Output in Node Console:
177198

178199
![](assets/node-rec.gif)
179-
180-
> If you want to use Danfo in frontend frameworks like React/Vue, read this [guide](https://danfo.jsdata.org/examples/using-danfojs-in-react)
181-
182200
## Notebook support
183201
* You can use Danfo.js on Dnotebooks playground [here](https://playnotebook.jsdata.org/demo)
184202
* VsCode nodejs notebook extension now supports Danfo.js. See guide [here](https://marketplace.visualstudio.com/items?itemName=donjayamanne.typescript-notebook)
@@ -205,4 +223,4 @@ All contributions, bug reports, bug fixes, documentation improvements, enhanceme
205223

206224
#### Created by [Rising Odegua](https://github.com/risenW) and [Stephen Oni](https://github.com/steveoni)
207225

208-
<a href="https://www.producthunt.com/posts/danfo-js?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-danfo-js" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=233871&theme=light" alt="Danfo.js - Open Source JavaScript library for manipulating data. | Product Hunt Embed" style="width: 250px; height: 54px;" width="250px" height="54px" /></a>
226+
<a href="https://www.producthunt.com/posts/danfo-js?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-danfo-js" target="_blank"><img src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=233871&theme=light" alt="Danfo.js - Open Source JavaScript library for manipulating data. | Product Hunt Embed" style="width: 250px; height: 54px;" width="250px" height="54px" /></a>

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
"danfojs-browser/**"
77
],
88
"scripts": {
9-
"build": "cd danfojs-node && yarn build:clean && cd ../danfojs-browser && yarn build:clean",
10-
"test": "cd danfojs-node && yarn && yarn test:clean && cd ../danfojs-browser && yarn && yarn test:clean"
9+
"install": "cd src/danfojs-base && yarn && cd ../danfojs-browser && yarn && cd ../danfojs-node && yarn",
10+
"build": "cd src/danfojs-node && yarn build:clean && cd ../danfojs-browser && yarn build:clean",
11+
"test": "cd src/danfojs-base && yarn && cd ../danfojs-node && yarn && yarn test:clean && cd ../danfojs-browser && yarn && yarn test:clean"
1112
}
1213
}

src/danfojs-base/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
## danfojs-base
2+
3+
**danfojs-base** is the core module of Danfo.js. Danfojs-node and Danfojs-browser folders simply extends/export this functions and classes from this module.
4+
5+
## Folders and Files
6+
7+
- __aggregators__: All files that contain functions that aggregate data.
8+
- __core__: Holds the core classes of Danfo.js.
9+
- `daterange`: Class that represents a date range.
10+
- `datetime`: Class that represents a date and time.
11+
- `frame`: Class that represents a frame.
12+
- `series`: Class that represents a series.
13+
- `generic`: Class that represents a generic object.
14+
- `indexing`: Class that represents an indexing.
15+
- `math.ops`: Class that represents a math operation.
16+
- `strings`: Class that represents a string.
17+
- __io__: Holds the IO classes of Danfo.js.
18+
- __browser__: Holds the browser IO classes.
19+
- `io.csv`: Holds the CSV IO classes.
20+
- `io.json`: Holds the JSON IO classes.
21+
- `io.excel`: Holds the excel IO classes.
22+
- __node__: Holds the node IO classes for Node.js
23+
- `io.csv`: Holds the CSV IO classes for Node.js
24+
- `io.json`: Holds the JSON IO classes for Node.js
25+
- `io.excel`: Holds the excel IO classes for Node.js
26+
- __plotting__: Holds the plotting classes
27+
- __plotly__: Holds the plotting class for Plotly charts.
28+
- __vega__: (Stub) Holds the plotting class for Vega charts.
29+
- __shared__
30+
- `config`: Holds the configuration class.
31+
- `defaults`: Holds the default values for the configuration class.
32+
- `errors`: Holds the error classes.
33+
- `tensorflowlib`: Autogenerated tensorflow library export.
34+
- `utils`: Holds the utility classes.
35+
- `types`: Holds the type classes.
36+
- __transformers__: Holds the transformers files
37+
- __encoders__: Holds the encoder classes.
38+
- `dummy.encoder`: Holds the dummy encoder class
39+
- `one.hot.encoder`: Holds the onehot encoder class
40+
- `label.encoder`: Holds the label encoder class
41+
- __scalers__
42+
- `min.max.scalers`: Holds the min max scaler class
43+
- `standard.scalers`: Holds the standard scaler class
44+
- `concat`: Holds the concatenation class
45+
- `merge`: Holds the merge class
46+
- `index.ts`: Entry point for the module.

0 commit comments

Comments
 (0)