Skip to content

Commit 8016d5e

Browse files
authored
Merge branch 'dev' into build-esm-bundle
2 parents ae70f90 + 0ec493e commit 8016d5e

11 files changed

Lines changed: 58 additions & 62 deletions

File tree

README.md

Lines changed: 45 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,15 @@ yarn add danfojs
7070
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:
7171

7272
```html
73-
<script src="https://cdn.jsdelivr.net/npm/danfojs@1.1.0/lib/bundle.js"></script>
73+
<script src="https://cdn.jsdelivr.net/npm/danfojs@1.1.1/lib/bundle.js"></script>
7474
```
7575
See all available versions [here](https://www.jsdelivr.com/package/npm/danfojs)
7676

7777
### Quick Examples
7878
* [Danfojs with HTML and vanilla JavaScript on CodePen](https://codepen.io/risingodegua/pen/bGpwyYW)
7979
* [Danfojs with React on Code Sandbox](https://codesandbox.io/s/using-danfojs-in-react-dwpv54?file=/src/App.js)
8080
* [Danfojs on ObservableHq](https://observablehq.com/@risingodegua/using-danfojs-on-observablehq)
81+
* [Danfojs in Nodejs on Replit](https://replit.com/@RisingOdegua/Danfojs-in-Nodejs)
8182

8283
### Example Usage in the Browser
8384
```html
@@ -87,7 +88,7 @@ See all available versions [here](https://www.jsdelivr.com/package/npm/danfojs)
8788
<head>
8889
<meta charset="UTF-8" />
8990
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
90-
<script src="https://cdn.jsdelivr.net/npm/danfojs@1.1.0/lib/bundle.js"></script>
91+
<script src="https://cdn.jsdelivr.net/npm/danfojs@1.1.1/lib/bundle.js"></script>
9192

9293
<title>Document</title>
9394
</head>
@@ -130,69 +131,62 @@ Output in Browser:
130131
### Example usage in Nodejs
131132

132133
```javascript
134+
const dfd = require("danfojs-node");
133135

134-
const dfd = require("danfojs-node")
136+
const file_url =
137+
"https://web.stanford.edu/class/archive/cs/cs109/cs109.1166/stuff/titanic.csv";
138+
dfd
139+
.readCSV(file_url)
140+
.then((df) => {
141+
//prints the first five columns
142+
df.head().print();
135143

136-
const file_url = "https://web.stanford.edu/class/archive/cs/cs109/cs109.1166/stuff/titanic.csv"
137-
dfd.readCSV(file_url)
138-
.then(df => {
139-
//prints the first five columns
140-
df.head().print()
144+
// Calculate descriptive statistics for all numerical columns
145+
df.describe().print();
141146

142-
// Calculate descriptive statistics for all numerical columns
143-
df.describe().print()
147+
//prints the shape of the data
148+
console.log(df.shape);
144149

145-
//prints the shape of the data
146-
console.log(df.shape);
150+
//prints all column names
151+
console.log(df.columns);
147152

148-
//prints all column names
149-
console.log(df.columns);
153+
// //prints the inferred dtypes of each column
154+
df.ctypes.print();
150155

151-
// //prints the inferred dtypes of each column
152-
df.ctypes.print()
156+
//selecting a column by subsetting
157+
df["Name"].print();
153158

154-
//selecting a column by subsetting
155-
df['Name'].print()
159+
//drop columns by names
160+
let cols_2_remove = ["Age", "Pclass"];
161+
let df_drop = df.drop({ columns: cols_2_remove, axis: 1 });
162+
df_drop.print();
156163

157-
//drop columns by names
158-
cols_2_remove = ['Age', 'Pclass']
159-
df_drop = df.drop({ columns: cols_2_remove, axis: 1 })
160-
df_drop.print()
164+
//select columns by dtypes
165+
let str_cols = df_drop.selectDtypes(["string"]);
166+
let num_cols = df_drop.selectDtypes(["int32", "float32"]);
167+
str_cols.print();
168+
num_cols.print();
161169

170+
//add new column to Dataframe
162171

163-
//select columns by dtypes
164-
let str_cols = df_drop.selectDtypes(["string"])
165-
let num_cols = df_drop.selectDtypes(["int32", "float32"])
166-
str_cols.print()
167-
num_cols.print()
172+
let new_vals = df["Fare"].round(1);
173+
df_drop.addColumn("fare_round", new_vals, { inplace: true });
174+
df_drop.print();
168175

169-
//select columns by dtypes
170-
let str_cols = df_drop.select_dtypes(["string"])
171-
let num_cols = df_drop.select_dtypes(["int32", "float32"])
172-
str_cols.print()
173-
num_cols.print()
176+
df_drop["fare_round"].round(2).print(5);
174177

175-
//add new column to Dataframe
178+
//prints the number of occurence each value in the column
179+
df_drop["Survived"].valueCounts().print();
176180

177-
let new_vals = df['Fare'].round(1)
178-
df_drop.addColumn("fare_round", new_vals, { inplace: true })
179-
df_drop.print()
180-
181-
df_drop['fare_round'].round(2).print(5)
182-
183-
//prints the number of occurence each value in the column
184-
df_drop['Survived'].valueCounts().print()
185-
186-
//print the last ten elementa of a DataFrame
187-
df_drop.tail(10).print()
188-
189-
//prints the number of missing values in a DataFrame
190-
df_drop.isNa().sum().print()
191-
192-
}).catch(err => {
193-
console.log(err);
194-
})
181+
//print the last ten elementa of a DataFrame
182+
df_drop.tail(10).print();
195183

184+
//prints the number of missing values in a DataFrame
185+
df_drop.isNa().sum().print();
186+
})
187+
.catch((err) => {
188+
console.log(err);
189+
});
196190

197191
```
198192
Output in Node Console:

src/danfojs-base/core/frame.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2102,7 +2102,7 @@ export default class DataFrame extends NDframe implements DataFrameInterface {
21022102
): DataFrame | void {
21032103
let { columns, inplace } = { inplace: false, ...options }
21042104

2105-
if (!values && typeof values !== "boolean" && typeof values !== "number") {
2105+
if (!values && typeof values !== "boolean" && typeof values !== "number" && typeof values !== "string") {
21062106
throw Error('ParamError: value must be specified');
21072107
}
21082108

src/danfojs-base/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import merge from "./transformers/merge"
2929
import dateRange from "./core/daterange"
3030
import tensorflow from "./shared/tensorflowlib"
3131

32-
const __version = "1.1.0";
32+
const __version = "1.1.1";
3333

3434
export {
3535
NDframe,

src/danfojs-base/io/browser/io.csv.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const $readCSV = async (file: any, options?: CsvInputOptionsBrowser): Promise<Da
5252
Papa.parse(file, {
5353
header: true,
5454
dynamicTyping: true,
55+
skipEmptyLines: 'greedy',
5556
...options,
5657
download: true,
5758
complete: results => {

src/danfojs-base/io/node/io.csv.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@ const $readCSV = async (filePath: string, options?: CsvInputOptionsNode): Promis
5555
const optionsWithDefaults = {
5656
header: true,
5757
dynamicTyping: true,
58+
skipEmptyLines: 'greedy',
5859
...options,
5960
}
6061

6162
const dataStream = request.get(filePath);
62-
const parseStream: any = Papa.parse(Papa.NODE_STREAM_INPUT, optionsWithDefaults);
63+
const parseStream: any = Papa.parse(Papa.NODE_STREAM_INPUT, optionsWithDefaults as any);
6364
dataStream.pipe(parseStream);
6465

6566
const data: any = [];

src/danfojs-base/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "danfojs-base",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "Base package used in danfojs-node and danfojs-browser",
55
"main": "index.ts",
66
"scripts": {

src/danfojs-browser/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ yarn add danfojs
7171
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:
7272

7373
```html
74-
<script src="https://cdn.jsdelivr.net/npm/danfojs@1.1.0/lib/bundle.js"></script>
74+
<script src="https://cdn.jsdelivr.net/npm/danfojs@1.1.1/lib/bundle.js"></script>
7575
```
7676
See all available versions [here](https://www.jsdelivr.com/package/npm/danfojs)
7777

@@ -86,7 +86,7 @@ See all available versions [here](https://www.jsdelivr.com/package/npm/danfojs)
8686
<head>
8787
<meta charset="UTF-8" />
8888
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
89-
<script src="https://cdn.jsdelivr.net/npm/danfojs@1.1.0/lib/bundle.js"></script>
89+
<script src="https://cdn.jsdelivr.net/npm/danfojs@1.1.1/lib/bundle.js"></script>
9090

9191
<title>Document</title>
9292
</head>

src/danfojs-browser/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "danfojs",
3-
"version": "1.1.0",
3+
"version": "1.1.1",
44
"description": "JavaScript library providing high performance, intuitive, and easy to use data structures for manipulating and processing structured data.",
55
"main": "dist/danfojs-browser/src/index.js",
66
"types": "dist/danfojs-browser/src/index.d.ts",

src/danfojs-browser/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"compilerOptions": {
33
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
4-
"module": "es2015", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
4+
"module": "CommonJS", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
55
"moduleResolution": "node",
66
"lib": ["es6", "dom"], /* Specify library files to be included in the compilation. */
77
"allowJs": true, /* Allow javascript files to be compiled. */

src/danfojs-node/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ yarn add danfojs
7171
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:
7272

7373
```html
74-
<script src="https://cdn.jsdelivr.net/npm/danfojs@1.1.0/lib/bundle.js"></script>
74+
<script src="https://cdn.jsdelivr.net/npm/danfojs@1.1.1/lib/bundle.js"></script>
7575
```
7676
See all available versions [here](https://www.jsdelivr.com/package/npm/danfojs)
7777

@@ -86,7 +86,7 @@ See all available versions [here](https://www.jsdelivr.com/package/npm/danfojs)
8686
<head>
8787
<meta charset="UTF-8" />
8888
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
89-
<script src="https://cdn.jsdelivr.net/npm/danfojs@1.1.0/lib/bundle.js"></script>
89+
<script src="https://cdn.jsdelivr.net/npm/danfojs@1.1.1/lib/bundle.js"></script>
9090

9191
<title>Document</title>
9292
</head>

0 commit comments

Comments
 (0)