Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd267db6

Browse files
committed
Merge branch 'dev'
2 parentsdfbf673 +65f9b37 commitd267db6

File tree

16 files changed

+501
-25
lines changed

16 files changed

+501
-25
lines changed

‎CONTRIBUTING.md

Lines changed: 286 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,286 @@
1+
#Contributing Guide
2+
3+
###Contributing to danfojs
4+
5+
**Table of contents:**
6+
7+
***TL:DR**
8+
* Where to start?
9+
* Working with the code
10+
* Version control, Git, and GitHub
11+
* Getting started with Git
12+
* Forking
13+
* Creating a development environment
14+
* Documentation Guidelines
15+
* Writing tests
16+
* Using mocha
17+
* Running the test suite
18+
* Contributing your changes to danfojs
19+
* Committing your code
20+
* Pushing your changes
21+
* Review your code and finally, make the pull request
22+
* Danfojs internal (Brief)
23+
24+
##TL:DR
25+
26+
All contributions, bug reports, bug fixes, documentation improvements, enhancements, and ideas are welcome.
27+
28+
For contributors familiar with open-source, below is a quick guide to setting up danfojs locally.
29+
30+
```
31+
git clone https://github.com/javascriptdata/danfojs.git
32+
cd danfojs
33+
git checkout -b <your-branch-name>
34+
```
35+
36+
There are three main folders in the`src` folder,**danfojs-base**,**danfojs-browser,** and**danfojs-node**.&#x20;
37+
38+
The**danfojs-base** folder holds all shared classes, modules, and functions used by both danfojs-browser and danfojs-node. So features or bug fixes that work the same way in both versions will generally be done in the**danfojs-base** folder.&#x20;
39+
40+
##Where to start?
41+
42+
For first-time contributors, you can find pending issues on the GitHub “issues” page. There are a number of issues listed and "good first issue" where you could start out. Once you’ve found an interesting issue, and have an improvement in mind, next thing is to set up your development environment.
43+
44+
##Working with the code
45+
46+
If you have an issue you want to fix, an enhancement to add, or documentation to improve, you need to learn how to work with GitHub and the Danfojs code base.
47+
48+
###**Version control, Git, and GitHub**
49+
50+
Danfojs code is hosted on GitHub. To contribute you will need to sign up for a free GitHub account. We use Git for version control to allow many people to work together on this project.
51+
52+
Some great resources for learning Git:
53+
54+
* Official[GitHub pages](http://help.github.com).
55+
56+
###**Getting started with Git**
57+
58+
Find[Instructions](http://help.github.com/set-up-git-redirect) for installing git, setting up your SSH key, and configuring git. These steps need to be completed before you can work seamlessly between your local repository and GitHub.
59+
60+
##**Forking the Danfojs repo**
61+
62+
You will need your own fork to work on the code. Go to the danfojs[project page](https://github.com/opensource9ja/danfojs) and hit the Fork button.
63+
64+
Next, you will clone your fork to your local machine:
65+
66+
```
67+
git clone https://github.com/javascriptdata/danfojs.git
68+
cd danfojs
69+
```
70+
71+
This creates the directory danfojs and connects your repository to the upstream (main project) repository.
72+
73+
Some Javascript features are supported both in the browser and node environment, and it is recommended to add features in the**danfojs-base** folder.&#x20;
74+
75+
For features that work differently or only in a specific environment, you can add them in the corresponding danfojs-node or danfojs-browser folder.&#x20;
76+
77+
78+
79+
##**Creating a development environment**
80+
81+
To test out code changes, you’ll need to build danfojs, which requires a Nodejs environment.
82+
83+
```python
84+
git clone https://github.com/javascriptdata/danfojs.git
85+
cd danfojs
86+
yarn install## automatically installs all required packages
87+
yarn test##Runs test in both node and browser folder
88+
```
89+
90+
>Now you can start adding features or fixing bugs!
91+
92+
##Documentation Guidelines
93+
94+
Documentation helps clarify what a function or a method is doing. It also gives insight to users of the function or methods on what parameters to pass in and know what the function will return.
95+
96+
Sample documentation:
97+
98+
```javascript
99+
/**
100+
* Add two series of the same length
101+
*@param{series1}series1 [Series]
102+
*@param{series2}series2 [Series]
103+
*@returns Series
104+
*/
105+
functionadd_series(series1,series2){
106+
107+
...................
108+
109+
returnnewSeries()
110+
}
111+
```
112+
113+
And for functions that contain more than two arguments, a keyword argument can be used. Parsing of keyword argument is also applicable to most of the methods in a class
114+
115+
```javascript
116+
/**
117+
* Join two or more dataframe together along an axis
118+
*@param{kwargs}kwargs --> {
119+
* df_list: [Array of DataFrame],
120+
* axis : int {0 or 1},
121+
* by_column : String {name of a column},
122+
* }
123+
*@returns DataFrame
124+
*/
125+
functionjoin_df(kwargs){
126+
........
127+
128+
return DataFrame
129+
}
130+
```
131+
132+
##**Writing tests**
133+
134+
We strongly encourage contributors to write tests for their code. Like many packages, Danfojs uses mocha.&#x20;
135+
136+
All tests should go into the tests subdirectory and placed in the corresponding module. The tests folder contains some current examples of tests, and we suggest looking to these for inspiration.
137+
138+
Below is the general Framework to write a test for each module.
139+
140+
{% tabs %}
141+
{% tab title="JavaScript" %}
142+
```javascript
143+
import {assert }from"chai"
144+
import {DataFrame }from'../../src/core/frame'
145+
146+
describe("Name of the class|module",function(){
147+
148+
it("name of the methods| expected result",function(){
149+
150+
//write your test code here
151+
//use assert.{proprty} to test your code
152+
})
153+
154+
});
155+
```
156+
{% endtab %}
157+
{% endtabs %}
158+
159+
For a class with lots of methods.
160+
161+
```python
162+
import {assert }from"chai"
163+
import { DataFrame }from'../../src/core/frame'
164+
165+
describe("Name of the class|module", function(){
166+
167+
describe("method name 1", function(){
168+
169+
it("expected result",function(){
170+
171+
//write your test code here
172+
//useassert.{proprty} to test your code
173+
})
174+
})
175+
176+
describe("method name 2", function(){
177+
178+
it("expected result",function(){
179+
180+
//write your test code here
181+
//useassert.{proprty} to test your code
182+
})
183+
})
184+
.......
185+
});
186+
```
187+
188+
**Example**: Let write a test, to test if the values in a dataframe are off a certain length. Assuming the method to obtain length is values\_len()
189+
190+
```javascript
191+
import {assert }from"chai"
192+
import {DataFrame }from'../../src/core/frame'
193+
194+
describe("DataFrame",function(){
195+
196+
describe("value_len",function(){
197+
198+
it("check dataframe length",function(){
199+
200+
let data= [[1,2],[4,5]]
201+
let columns= ["A","B"]
202+
let df=newDataFrame(data,{columns: columns})
203+
204+
let expected_result=2
205+
206+
assert.deepEqual(sf.value_len(), expected_result))
207+
208+
209+
})
210+
})
211+
212+
});
213+
```
214+
215+
###**Running the test case**
216+
217+
To run the test for the module you created,
218+
219+
**1)** Open the package.json
220+
221+
**2)** change the name of the test script to the file name you want to test.
222+
223+
```python
224+
"scripts": {
225+
"test":"....... danfojs/tests/sub_directory_name/filename",
226+
```
227+
228+
**3)** run the test,in the danfojs directory terminal
229+
230+
```python
231+
yarn test
232+
```
233+
234+
Learn more about mocha [here](https://mochajs.org)
235+
236+
## Contributing your changes to danfojs
237+
238+
### **Committing your code**
239+
240+
Once you’ve made changes, you can see them by typing:
241+
242+
```
243+
git status
244+
```
245+
246+
Next, you can track your changes using
247+
248+
```
249+
git add .
250+
```
251+
252+
Next, you commit changes using:
253+
254+
```
255+
git commit-m"Enter any commit message here"
256+
```
257+
258+
### **Pushing your changes**
259+
260+
When you want your changes to appear publicly on your GitHub page, you can push to your forked repowith:
261+
262+
```
263+
git push
264+
```
265+
266+
### Review your code and finally, make a pull request
267+
268+
If everything looks good, you are ready to make a pull request. A pull requestis how codefrom a local repository becomes available to the GitHub communityand can be reviewedand eventually merged into the master version. To submit a pull request:
269+
270+
1. Navigate to your repository on GitHub
271+
2. Click on the Pull Request button
272+
3. Write a description of your changesin the Preview Discussion tab
273+
4. Click Send Pull Request.
274+
275+
This request then goes to the repository maintainers,and they will review the codeand everything looks good, merge itwith the master.
276+
277+
**Hooray! You're now a contributor to danfojs. Now go bask in the euphoria!**
278+
279+
## **Danfojs Internals**
280+
281+
In other to contribute to the code base of danfojs, there are some functionsand properties provided to make implementation easy.
282+
283+
The folder**danfojs-base** contains the bulk of Danfojs modules,and these are simply extendedor exported by the**danfojs-browser**and**danfojs-node** folders. The baseclassfor Framesand Seriesis the NdFrameclass whichis foundin the`danfojs-base/core/generic`file.&#x20;
284+
285+
286+

‎README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ 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-
<scriptsrc="https://cdn.jsdelivr.net/npm/danfojs@1.0.0/lib/bundle.js"></script>
73+
<scriptsrc="https://cdn.jsdelivr.net/npm/danfojs@1.0.1/lib/bundle.js"></script>
7474
```
7575
See all available versions[here](https://www.jsdelivr.com/package/npm/danfojs)
7676

@@ -85,7 +85,7 @@ See all available versions [here](https://www.jsdelivr.com/package/npm/danfojs)
8585
<head>
8686
<metacharset="UTF-8" />
8787
<metaname="viewport"content="width=device-width, initial-scale=1.0" />
88-
<scriptsrc="https://cdn.jsdelivr.net/npm/danfojs@1.0.0/lib/bundle.js"></script>
88+
<scriptsrc="https://cdn.jsdelivr.net/npm/danfojs@1.0.1/lib/bundle.js"></script>
8989

9090
<title>Document</title>
9191
</head>

‎src/danfojs-base/aggregators/groupby.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,14 @@ export default class Groupby {
441441
returnthis.operations("sum")
442442
}
443443

444+
/**
445+
* Obtain the standard deviation of columns for each group
446+
*@returns DataFrame
447+
*/
448+
std():DataFrame{
449+
returnthis.operations("std")
450+
}
451+
444452
/**
445453
* Obtain the variance of columns for each group
446454
*@returns DataFrame

‎src/danfojs-base/core/frame.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2754,14 +2754,18 @@ export default class DataFrame extends NDframe implements DataFrameInterface {
27542754
*
27552755
*/
27562756
rename(
2757-
mapper:any,
2757+
mapper:{
2758+
[index:string|number]:string|number
2759+
},
27582760
options?:{
27592761
axis?:0|1
27602762
inplace?:boolean
27612763
}
27622764
):DataFrame
2763-
rename(
2764-
mapper:any,
2765+
rename(
2766+
mapper:{
2767+
[index:string|number]:string|number
2768+
},
27652769
options?:{
27662770
axis?:0|1
27672771
inplace?:boolean
@@ -2777,8 +2781,9 @@ export default class DataFrame extends NDframe implements DataFrameInterface {
27772781
constcolsAdded:string[]=[];
27782782
constnewColumns=this.columns.map(col=>{
27792783
if(mapper[col]!==undefined){
2780-
colsAdded.push(mapper[col]);
2781-
returnmapper[col]
2784+
constnewCol=`${mapper[col]}`;
2785+
colsAdded.push(newCol);
2786+
returnnewCol;
27822787
}else{
27832788
returncol
27842789
}

‎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
importdateRangefrom"./core/daterange"
3030
importtensorflowfrom"./shared/tensorflowlib"
3131

32-
const__version="1.0.0"
32+
const__version="1.0.1";
3333

3434
export{
3535
NDframe,

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ const $readCSV = async (file: any, options?: CsvInputOptionsBrowser): Promise<Da
5151
returnnewPromise(resolve=>{
5252
Papa.parse(file,{
5353
header:true,
54+
dynamicTyping:true,
5455
...options,
5556
download:true,
5657
complete:results=>{
@@ -83,6 +84,7 @@ const $streamCSV = async (file: string, callback: (df: DataFrame) => void, optio
8384
letcount=-1
8485
Papa.parse(file,{
8586
...options,
87+
dynamicTyping:true,
8688
header:true,
8789
download:true,
8890
step:results=>{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp