Skip to content

Commit 1e35153

Browse files
committed
Update docstrings and Readme
1 parent 759b594 commit 1e35153

25 files changed

Lines changed: 173 additions & 103 deletions

File tree

src/danfojs-base/README.md

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,46 @@
11
## danfojs-base
22

3-
**danfojs-base** is the core module of Danfo.js. Danfojs-node and Danfojs-browser folders simply extends/export this module, and customizes some functionality to work in the respective environments.
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.
44

55
## Folders and Files
66

7-
- aggregators:
8-
- core: Holds the core classes of Danfo.js.
9-
- datetime: Holds the datetime classes of Danfo.
10-
11-
- shared
12-
- transformers
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
1346
- `index.ts`: Entry point for the module.

src/danfojs-base/core/frame.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1837,7 +1837,7 @@ export default class DataFrame extends NDframe implements DataFrameInterface {
18371837
* @example
18381838
* ```
18391839
* const df = new DataFrame([[1, 2], [3, 4]], { columns: ['A', 'B']})
1840-
* df.isNaN().print()
1840+
* df.isNa().print()
18411841
* ```
18421842
*/
18431843
isNa(): DataFrame {

src/danfojs-base/core/indexing.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { NDframeInterface } from "../shared/types";
2121
const utils = new Utils();
2222

2323
/**
24-
* Slice a Series/DataFrame by specified string location based labels
24+
* Internal function to slice a Series/DataFrame by index based labels
2525
* @param Object
2626
*/
2727
export function _iloc({ ndFrame, rows, columns }: {
@@ -206,7 +206,7 @@ export function _iloc({ ndFrame, rows, columns }: {
206206
}
207207

208208
/**
209-
* Slice a Series/DataFrame by specified string location based labels
209+
* Internal function to slice a Series/DataFrame by specified string location based labels
210210
* @param Object
211211
*/
212212
export function _loc({ ndFrame, rows, columns }: {

src/danfojs-base/core/math.ops.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Utils from "../shared/utils"
1818
const utils = new Utils();
1919

2020
/**
21-
* Generic function for performing add, sub, pow, mul and mod operation on a series
21+
* Generic function for performing math operations on a series
2222
* @param object
2323
*
2424
* ndframe ==> The current Series

src/danfojs-base/core/series.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,16 @@ import {
4343

4444
const utils = new Utils();
4545

46+
4647
/**
4748
* One-dimensional ndarray with axis labels.
4849
* The object supports both integer- and label-based indexing and provides a host of methods for performing operations involving the index.
49-
* Operations between DataFrame (+, -, /, , *) align values based on their associated index values– they need not be the same length.
50-
* @param data 2D Array, JSON, Tensor, Block of data.
51-
* @param options.index Array of numeric or string names for subseting array. If not specified, indexes are auto generated.
52-
* @param options.columns Array of column names. If not specified, column names are auto generated.
53-
* @param options.dtypes Array of data types for each the column. If not specified, dtypes are/is inferred.
54-
* @param options.config General configuration object for extending or setting NDframe behavior.
50+
* Operations between Series (+, -, /, , *) align values based on their associated index values – they need not be the same length.
51+
* @param data 1D Array, JSON, Tensor, Block of data.
52+
* @param options.index Array of numeric or string index for subseting array. If not specified, indices are auto generated.
53+
* @param options.columns Column name. This is like the name of the Series. If not specified, column name is set to 0.
54+
* @param options.dtypes Data types of the Series data. If not specified, dtypes is inferred.
55+
* @param options.config General configuration object for extending or setting Series behavior.
5556
*/
5657
export default class Series extends NDframe implements SeriesInterface {
5758

src/danfojs-base/core/strings.ts

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@
1313
* ==========================================================================
1414
*/
1515
import { ArrayType1D } from "../shared/types";
16+
import Utils from "../shared/utils"
1617
import Series from "./series";
1718

19+
const utils = new Utils();
1820
/**
1921
* Exposes numerous String methods. All methods are applied Element-wise
2022
*/
@@ -45,7 +47,7 @@ export default class Str {
4547
const { inplace } = { inplace: false, ...options }
4648
const newArr: Array<string | number> = [];
4749
this.values.map((val) => {
48-
if (isNaN(val as number) && typeof val != "string") {
50+
if (utils.isEmpty(val)) {
4951
newArr.push(NaN);
5052
} else {
5153
newArr.push(`${val}`.toLowerCase());
@@ -82,7 +84,7 @@ export default class Str {
8284
const { inplace } = { inplace: false, ...options }
8385
const newArr: Array<string | number> = [];
8486
this.values.map((val) => {
85-
if (isNaN(val as number) && typeof val != "string") {
87+
if (utils.isEmpty(val)) {
8688
newArr.push(NaN);
8789
} else {
8890
newArr.push(`${val}`.toUpperCase());
@@ -118,7 +120,7 @@ export default class Str {
118120
const { inplace } = { inplace: false, ...options }
119121
const newArr: Array<string | number> = [];
120122
this.values.map((val) => {
121-
if (isNaN(val as number) && typeof val != "string") {
123+
if (utils.isEmpty(val)) {
122124
newArr.push(NaN);
123125
} else {
124126
let firstChar = `${val}`.slice(0, 1);
@@ -159,7 +161,7 @@ export default class Str {
159161
const { inplace } = { inplace: false, ...options }
160162
const newArr: Array<string | number> = [];
161163
this.values.map((val) => {
162-
if (isNaN(val as number) && typeof val != "string") {
164+
if (utils.isEmpty(val)) {
163165
newArr.push(NaN);
164166
} else {
165167
newArr.push(`${val}`.charAt(index));
@@ -209,14 +211,14 @@ export default class Str {
209211
} else {
210212
this.values.map((val) => {
211213
if (position == 1) {
212-
if (isNaN(val as number) && typeof val != "string") {
214+
if (utils.isEmpty(val)) {
213215
newArr.push(NaN);
214216
} else {
215217
newArr.push(`${val}`.concat(`${other}`));
216218
}
217219

218220
} else {
219-
if (isNaN(val as number) && typeof val != "string") {
221+
if (utils.isEmpty(val)) {
220222
newArr.push(NaN);
221223
} else {
222224
newArr.push(other.concat(`${val}`));
@@ -256,7 +258,7 @@ export default class Str {
256258
const { inplace } = { inplace: false, ...options }
257259
const newArr: Array<boolean | number> = [];
258260
this.values.forEach((val) => {
259-
if (isNaN(val as number) && typeof val != "string") {
261+
if (utils.isEmpty(val)) {
260262
newArr.push(NaN);
261263
} else {
262264
newArr.push(`${val}`.startsWith(str));
@@ -291,7 +293,7 @@ export default class Str {
291293
const { inplace } = { inplace: false, ...options }
292294
const newArr: Array<boolean | number> = [];
293295
this.values.map((val) => {
294-
if (isNaN(val as number) && typeof val != "string") {
296+
if (utils.isEmpty(val)) {
295297
newArr.push(NaN);
296298
} else {
297299
newArr.push(`${val}`.endsWith(str));
@@ -326,7 +328,7 @@ export default class Str {
326328
const { inplace } = { inplace: false, ...options }
327329
const newArr: Array<boolean | number> = [];
328330
this.values.map((val) => {
329-
if (isNaN(val as number) && typeof val != "string") {
331+
if (utils.isEmpty(val)) {
330332
newArr.push(NaN);
331333
} else {
332334
newArr.push(`${val}`.includes(str));
@@ -361,7 +363,7 @@ export default class Str {
361363
const { inplace } = { inplace: false, ...options }
362364
const newArr: Array<number> = [];
363365
this.values.map((val) => {
364-
if (isNaN(val as number) && typeof val != "string") {
366+
if (utils.isEmpty(val)) {
365367
newArr.push(NaN);
366368
} else {
367369
newArr.push(`${val}`.indexOf(str));
@@ -396,7 +398,7 @@ export default class Str {
396398
const { inplace } = { inplace: false, ...options }
397399
const newArr: Array<string | number> = [];
398400
this.values.map((val) => {
399-
if (isNaN(val as number) && typeof val != "string") {
401+
if (utils.isEmpty(val)) {
400402
newArr.push(NaN);
401403
} else {
402404
newArr.push(`${val}`.lastIndexOf(str));
@@ -433,7 +435,7 @@ export default class Str {
433435
const { inplace } = { inplace: false, ...options }
434436
const newArr: Array<string | number> = [];
435437
this.values.map((val) => {
436-
if (isNaN(val as number) && typeof val != "string") {
438+
if (utils.isEmpty(val)) {
437439
newArr.push(NaN);
438440
} else {
439441
newArr.push(`${val}`.replace(searchValue, replaceValue));
@@ -468,7 +470,7 @@ export default class Str {
468470
const { inplace } = { inplace: false, ...options }
469471
const newArr: Array<string | number> = [];
470472
this.values.map((val) => {
471-
if (isNaN(val as number) && typeof val != "string") {
473+
if (utils.isEmpty(val)) {
472474
newArr.push(NaN);
473475
} else {
474476
newArr.push(`${val}`.repeat(num));
@@ -503,7 +505,7 @@ export default class Str {
503505
const { inplace } = { inplace: false, ...options }
504506
const newArr: Array<string | number> = [];
505507
this.values.map((val) => {
506-
if (isNaN(val as number) && typeof val != "string") {
508+
if (utils.isEmpty(val)) {
507509
newArr.push(NaN);
508510
} else {
509511
newArr.push(`${val}`.search(str));
@@ -539,7 +541,7 @@ export default class Str {
539541
const { inplace } = { inplace: false, ...options }
540542
const newArr: Array<string | number> = [];
541543
this.values.map((val) => {
542-
if (isNaN(val as number) && typeof val != "string") {
544+
if (utils.isEmpty(val)) {
543545
newArr.push(NaN);
544546
} else {
545547
newArr.push(`${val}`.slice(startIndex, endIndex));
@@ -573,7 +575,7 @@ export default class Str {
573575
const { inplace } = { inplace: false, ...options }
574576
const newArr: Array<string | number> = [];
575577
this.values.map((val) => {
576-
if (isNaN(val as number) && typeof val != "string") {
578+
if (utils.isEmpty(val)) {
577579
newArr.push(NaN);
578580
} else {
579581
newArr.push(`${String(val).split(splitVal)}`);
@@ -607,7 +609,7 @@ export default class Str {
607609
const { inplace } = { inplace: false, ...options }
608610
const newArr: Array<string | number> = [];
609611
this.values.map((val) => {
610-
if (isNaN(val as number) && typeof val != "string") {
612+
if (utils.isEmpty(val)) {
611613
newArr.push(NaN);
612614
} else {
613615
newArr.push(`${String(val).substr(startIndex, num)}`);
@@ -641,7 +643,7 @@ export default class Str {
641643
const { inplace } = { inplace: false, ...options }
642644
const newArr: Array<string | number> = [];
643645
this.values.map((val) => {
644-
if (isNaN(val as number) && typeof val != "string") {
646+
if (utils.isEmpty(val)) {
645647
newArr.push(NaN);
646648
} else {
647649
newArr.push(`${String(val).substring(startIndex, endIndex)}`);
@@ -674,7 +676,7 @@ export default class Str {
674676
const { inplace } = { inplace: false, ...options }
675677
const newArr: Array<string | number> = [];
676678
this.values.map((val) => {
677-
if (isNaN(val as number) && typeof val != "string") {
679+
if (utils.isEmpty(val)) {
678680
newArr.push(NaN);
679681
} else {
680682
newArr.push(`${val}`.trim());
@@ -709,7 +711,7 @@ export default class Str {
709711
const { inplace } = { inplace: false, ...options }
710712
const newArr: Array<string | number> = [];
711713
this.values.map((val) => {
712-
if (isNaN(val as number) && typeof val != "string") {
714+
if (utils.isEmpty(val)) {
713715
newArr.push(NaN);
714716
} else {
715717
let leftChar = val;
@@ -745,7 +747,7 @@ export default class Str {
745747
const { inplace } = { inplace: false, ...options }
746748
const newArr: Array<string | number> = [];
747749
this.values.map((val) => {
748-
if (isNaN(val as number) && typeof val != "string") {
750+
if (utils.isEmpty(val)) {
749751
newArr.push(NaN);
750752
} else {
751753
newArr.push(`${val}`.length);

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ import {
1616
$readCSV,
1717
$streamCSV,
1818
$toCSV,
19-
// $openCsvInputStream,
20-
// $writeCsvOutputStream,
2119
} from "./io.csv"
2220
import {
2321
$readJSON,
@@ -29,8 +27,6 @@ export {
2927
$readCSV as readCSVBrowser,
3028
$streamCSV as streamCSVBrowser,
3129
$toCSV as toCSVBrowser,
32-
// $openCsvInputStream as openCsvInputStream,
33-
// $writeCsvOutputStream as writeCsvOutputStream,
3430
$readJSON as readJSONBrowser,
3531
$toJSON as toJSONBrowser,
3632
$readExcel as readExcelBrowser,

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
* limitations under the License.
1313
* ==========================================================================
1414
*/
15-
import Papa from 'papaparse'
16-
import { DataFrame, NDframe, Series } from '../../'
1715
import { CsvInputOptionsBrowser, CsvOutputOptionsBrowser, ArrayType2D} from "../../shared/types"
16+
import { DataFrame, NDframe, Series } from '../../'
17+
import Papa from 'papaparse'
1818

1919

2020
/**
@@ -150,7 +150,7 @@ const $toCSV = (df: NDframe | DataFrame | Series, options?: CsvOutputOptionsBrow
150150
};
151151

152152
/**
153-
* Function to download a CSV file in the browser.
153+
* Internal function to download a CSV file in the browser.
154154
* @param content A string of CSV file contents
155155
* @param fileName The name of the file to be downloaded
156156
*/

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,14 @@
1212
* limitations under the License.
1313
* ==========================================================================
1414
*/
15-
import XLSX from 'xlsx';
15+
import {
16+
ArrayType1D,
17+
ArrayType2D,
18+
ExcelOutputOptionsBrowser,
19+
ExcelInputOptionsBrowser
20+
} from "../../shared/types"
1621
import { DataFrame, NDframe, Series } from '../../'
17-
import { ArrayType1D, ArrayType2D, ExcelOutputOptionsBrowser, ExcelInputOptionsBrowser } from "../../shared/types"
22+
import XLSX from 'xlsx';
1823

1924
/**
2025
* Reads a JSON file from local or remote location into a DataFrame.

0 commit comments

Comments
 (0)