Skip to content

Commit f58d17e

Browse files
authored
Merge branch 'master' into danfojs-browser
2 parents 45a30fc + dafcd2f commit f58d17e

7 files changed

Lines changed: 84 additions & 8 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Desktop (please complete the following information):**
27+
- OS: [e.g. iOS]
28+
- Browser [e.g. chrome, safari]
29+
- Version [e.g. 22]
30+
31+
**Smartphone (please complete the following information):**
32+
- Device: [e.g. iPhone6]
33+
- OS: [e.g. iOS8.1]
34+
- Browser [e.g. stock browser, safari]
35+
- Version [e.g. 22]
36+
37+
**Additional context**
38+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ easy and intuitive. It is heavily inspired by [Pandas](https://pandas.pydata.org
4949

5050

5151

52-
To use Danfo.js via script tags, copy and paste the CDN below to your HTML file
52+
To use Danfo.js via script tags, copy and paste the CDN below to the body of your HTML file
5353

5454
```html
5555
<script src="https://cdn.jsdelivr.net/npm/danfojs@0.2.2/lib/bundle.min.js"></script>
@@ -66,11 +66,11 @@ To use Danfo.js via script tags, copy and paste the CDN below to your HTML file
6666
<head>
6767
<meta charset="UTF-8">
6868
<meta name="viewport" content="width=device-width, initial-scale=1.0">
69-
<script src="https://cdn.jsdelivr.net/npm/danfojs@0.2.2/lib/bundle.min.js"></script>
7069
<title>Document</title>
7170
</head>
7271

7372
<body>
73+
<script src="https://cdn.jsdelivr.net/npm/danfojs@0.2.2/lib/bundle.min.js"></script>
7474

7575
<div id="div1"></div>
7676
<div id="div2"></div>
@@ -175,6 +175,8 @@ Output in Node Console:
175175

176176
![](assets/node-rec.gif)
177177

178+
> If you want to use Danfo in frontend frameworks like React/Vue, read this [guide](https://danfo.jsdata.org/examples/using-danfojs-in-react)
179+
178180
#### You can play with Danfo.js on Dnotebooks playground [here](https://playnotebook.jsdata.org/demo)
179181

180182
#### [See the Official Getting Started Guide](https://danfo.jsdata.org/getting-started)

danfojs/src/core/generic.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export default class NDframe {
102102
) {
103103
this.columns = this.kwargs["columns"];
104104
} else {
105-
throw `Column length mismatch. You provided a column of length ${this.kwargs["columns"].length} but data has lenght of ${this.row_data_tensor.shape[1]}`;
105+
throw `Column length mismatch. You provided a column of length ${this.kwargs["columns"].length} but data has length of ${this.row_data_tensor.shape[1]}`;
106106
}
107107
} else {
108108
this.columns = [ ...Array(this.row_data_tensor.shape[1]).keys() ];

danfojs/src/core/utils.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -615,12 +615,11 @@ export class Utils {
615615

616616
__shuffle(num, array) {
617617
//https://stackoverflow.com/questions/18806210/generating-non-repeating-random-numbers-in-js/18806417
618-
var i = array.length,
619-
j = 0,
618+
var j,
620619
temp;
621620

622-
while (i--) {
623-
j = Math.floor(Math.random() * (i + 1));
621+
for (let i = 0; i < num; i++) {
622+
j = Math.floor(Math.random() * (array.length - i)) + i;
624623

625624
// swap randomly chosen element with current element
626625
temp = array[i];

danfojs/tests/core/utils.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,4 +217,20 @@ describe("Utils Functions", function () {
217217
});
218218
});
219219

220+
describe("__shuffle", function() {
221+
it("returns array with correct shape", function() {
222+
let data = [ 1, 2, 3, 4, 5 ];
223+
assert.deepEqual(utils.__shuffle(3, data).length, 3);
224+
});
225+
226+
it("returns original values when num equals total length", function() {
227+
let data = [ 1, 2, 3, 4, 5 ];
228+
assert.deepEqual(utils.__shuffle(5, data).sort(), [ 1, 2, 3, 4, 5 ]);
229+
});
230+
231+
it("returns empty array when num equals zero", function() {
232+
let data = [ 1, 2, 3, 4, 5 ];
233+
assert.deepEqual(utils.__shuffle(0, data), []);
234+
});
235+
});
220236
});

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@
7575
"mocha": "^8.3.0",
7676
"nyc": "^15.1.0",
7777
"webpack": "5.21.2",
78-
"webpack-cli": "^4.5.0"
78+
"webpack-cli": "4.5.0",
79+
"yarn": "^1.22.10"
7980
},
8081
"nyc": {
8182
"reporter": [

0 commit comments

Comments
 (0)