Skip to content

Commit ddb7370

Browse files
authored
Merge pull request #285 from opensource9ja/optimize/internal
Optimize/internal
2 parents 1554a40 + a530fdc commit ddb7370

File tree

123 files changed

+15617
-21457
lines changed

Some content is hidden

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

123 files changed

+15617
-21457
lines changed

.github/workflows/node.js.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ jobs:
2525
with:
2626
node-version: ${{ matrix.node-version }}
2727
- run: cd danfojs-node && yarn
28-
- run: cd danfojs-node && yarn test
28+
- run: cd danfojs-node && yarn test:clean
2929
- run: cd danfojs-browser && yarn
30-
- run: cd danfojs-browser && yarn test
30+
- run: cd danfojs-browser && yarn test:clean

danfojs-browser/.eslintrc.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,11 @@
2323
"before": false, "after": true
2424
}
2525
],
26-
"indent": [ "error",
27-
2
28-
],
2926
"keyword-spacing": [
3027
"error",
3128
{ "before": true
3229
}
3330
],
34-
"array-bracket-spacing": [ "error", "always"
35-
],
3631
"space-infix-ops": "error",
3732
"object-curly-spacing": [ "error", "always"
3833
],

danfojs-browser/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ danfojs/data
66
.DS_Store
77
.idea/
88

9-
dist/
9+
dist/
10+
lib/

danfojs-browser/README.md

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ To use Danfo.js via script tags, copy and paste the CDN below to the body of you
8686
8787
df.plot("div2").table() //display csv as table
8888
89-
new_df = df.set_index({ key: "Date" }) //resets the index to Date column
89+
new_df = df.set_index({ column: "Date" }) //resets the index to Date column
9090
new_df.plot("div3").line({ columns: ["AAPL.Open", "AAPL.High"] }) //makes a timeseries plot
9191
9292
}).catch(err => {
@@ -117,59 +117,61 @@ npm install danfojs-node
117117

118118
const dfd = require("danfojs-node")
119119

120+
const file_url = "https://web.stanford.edu/class/archive/cs/cs109/cs109.1166/stuff/titanic.csv"
121+
dfd.read_csv(file_url)
122+
.then(df => {
123+
//prints the first five columns
124+
df.head().print()
120125

121-
dfd.read_csv("https://web.stanford.edu/class/archive/cs/cs109/cs109.1166/stuff/titanic.csv")
122-
.then(df => {
123-
//prints the first five columns
124-
df.head().print()
126+
// Calculate descriptive statistics for all numerical columns
127+
df.describe().print()
125128

126-
//Calculate descriptive statistics for all numerical columns
127-
df.describe().print()
129+
//prints the shape of the data
130+
console.log(df.shape);
128131

129-
//prints the shape of the data
130-
console.log(df.shape);
132+
//prints all column names
133+
console.log(df.columns);
131134

132-
//prints all column names
133-
console.log(df.column_names);
135+
// //prints the inferred dtypes of each column
136+
df.ctypes.print()
134137

135-
//prints the inferred dtypes of each column
136-
df.ctypes.print()
138+
//selecting a column by subsetting
139+
df['Name'].print()
137140

138-
//selecting a column by subsetting
139-
df['Name'].print()
141+
//drop columns by names
142+
cols_2_remove = ['Age', 'Pclass']
143+
df_drop = df.drop({ columns: cols_2_remove, axis: 1 })
144+
df_drop.print()
140145

141-
//drop columns by names
142-
cols_2_remove = ['Age', 'Pclass']
143-
df_drop = df.drop({ columns: cols_2_remove, axis: 1 })
144-
df_drop.print()
145146

147+
//select columns by dtypes
148+
let str_cols = df_drop.select_dtypes(["string"])
149+
let num_cols = df_drop.select_dtypes(["int32", "float32"])
150+
str_cols.print()
151+
num_cols.print()
146152

147-
//select columns by dtypes
148-
let str_cols = df_drop.select_dtypes(["string"])
149-
let num_cols = df_drop.select_dtypes(["int32", "float32"])
150-
str_cols.print()
151-
num_cols.print()
152153

154+
//add new column to Dataframe
153155

154-
//add new column to Dataframe
155-
let new_vals = df['Fare'].round().values
156-
df_drop.addColumn({ column: "fare_round", value: new_vals})
157-
df_drop.print()
156+
let new_vals = df['Fare'].round(1)
157+
df_drop.addColumn({ column: "fare_round", values: new_vals, inplace: true })
158+
df_drop.print()
158159

159-
df_drop['fare_round'].print(5)
160+
df_drop['fare_round'].round(2).print(5)
160161

161-
//prints the number of occurence each value in the column
162-
df_drop['Survived'].value_counts().print()
162+
//prints the number of occurence each value in the column
163+
df_drop['Survived'].value_counts().print()
163164

164-
//print the last ten elementa of a DataFrame
165-
df_drop.tail(10).print()
165+
//print the last ten elementa of a DataFrame
166+
df_drop.tail(10).print()
166167

167-
//prints the number of missing values in a DataFrame
168-
df_drop.isna().sum().print()
168+
//prints the number of missing values in a DataFrame
169+
df_drop.isna().sum().print()
170+
171+
}).catch(err => {
172+
console.log(err);
173+
})
169174

170-
}).catch(err => {
171-
console.log(err);
172-
})
173175

174176
```
175177
Output in Node Console:

danfojs-browser/babel.config.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

danfojs-browser/lib/bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

danfojs-browser/lib/bundle.js.LICENSE.txt

Lines changed: 0 additions & 198 deletions
This file was deleted.

danfojs-browser/lib/bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)