diff --git a/.gitbook/assets/419nr0t2zml.jpeg b/.gitbook/assets/419nr0t2zml.jpeg deleted file mode 100644 index 971413a..0000000 Binary files a/.gitbook/assets/419nr0t2zml.jpeg and /dev/null differ diff --git a/.gitbook/assets/b17076_cover.jpg b/.gitbook/assets/b17076_cover.jpg deleted file mode 100644 index 726b939..0000000 Binary files a/.gitbook/assets/b17076_cover.jpg and /dev/null differ diff --git a/.gitbook/assets/image (4).png b/.gitbook/assets/image (4).png deleted file mode 100644 index fc601b5..0000000 Binary files a/.gitbook/assets/image (4).png and /dev/null differ diff --git a/.gitbook/assets/newplot (2) (1) (1).png b/.gitbook/assets/newplot (2) (1) (1).png new file mode 100644 index 0000000..9f34611 Binary files /dev/null and b/.gitbook/assets/newplot (2) (1) (1).png differ diff --git a/.gitbook/assets/newplot (2) (1) (2).png b/.gitbook/assets/newplot (2) (1) (2).png new file mode 100644 index 0000000..9f34611 Binary files /dev/null and b/.gitbook/assets/newplot (2) (1) (2).png differ diff --git a/.gitbook/assets/newplot (2) (1) (3).png b/.gitbook/assets/newplot (2) (1) (3).png new file mode 100644 index 0000000..9f34611 Binary files /dev/null and b/.gitbook/assets/newplot (2) (1) (3).png differ diff --git a/.gitbook/assets/newplot (2) (1).png b/.gitbook/assets/newplot (2) (1).png new file mode 100644 index 0000000..9f34611 Binary files /dev/null and b/.gitbook/assets/newplot (2) (1).png differ diff --git a/.gitbook/assets/newplot (2) (2) (1).png b/.gitbook/assets/newplot (2) (2) (1).png new file mode 100644 index 0000000..9f34611 Binary files /dev/null and b/.gitbook/assets/newplot (2) (2) (1).png differ diff --git a/.gitbook/assets/newplot (2) (2).png b/.gitbook/assets/newplot (2) (2).png new file mode 100644 index 0000000..9f34611 Binary files /dev/null and b/.gitbook/assets/newplot (2) (2).png differ diff --git a/.gitbook/assets/newplot-1-.png b/.gitbook/assets/newplot-1-.png deleted file mode 100644 index 8ec8c53..0000000 Binary files a/.gitbook/assets/newplot-1-.png and /dev/null differ diff --git a/.gitbook/assets/newplot-11-.png b/.gitbook/assets/newplot-11-.png deleted file mode 100644 index e916b5c..0000000 Binary files a/.gitbook/assets/newplot-11-.png and /dev/null differ diff --git a/.gitbook/assets/newplot-13-.png b/.gitbook/assets/newplot-13-.png deleted file mode 100644 index 3f01471..0000000 Binary files a/.gitbook/assets/newplot-13-.png and /dev/null differ diff --git a/.gitbook/assets/newplot-14-.png b/.gitbook/assets/newplot-14-.png deleted file mode 100644 index 6b3a1b2..0000000 Binary files a/.gitbook/assets/newplot-14-.png and /dev/null differ diff --git a/.gitbook/assets/newplot-15-.png b/.gitbook/assets/newplot-15-.png deleted file mode 100644 index a5886e7..0000000 Binary files a/.gitbook/assets/newplot-15-.png and /dev/null differ diff --git a/.gitbook/assets/newplot-2- (1) (1) (1).png b/.gitbook/assets/newplot-2- (1) (1) (1).png new file mode 100644 index 0000000..9f34611 Binary files /dev/null and b/.gitbook/assets/newplot-2- (1) (1) (1).png differ diff --git a/.gitbook/assets/newplot-23-.png b/.gitbook/assets/newplot-23-.png deleted file mode 100644 index 1fb937a..0000000 Binary files a/.gitbook/assets/newplot-23-.png and /dev/null differ diff --git a/.gitbook/assets/newplot-29- (2) (1) (1) (1).png b/.gitbook/assets/newplot-29- (2) (1) (1) (1).png new file mode 100644 index 0000000..a884a20 Binary files /dev/null and b/.gitbook/assets/newplot-29- (2) (1) (1) (1).png differ diff --git a/.gitbook/assets/newplot-29- (2) (1) (1) (2).png b/.gitbook/assets/newplot-29- (2) (1) (1) (2).png new file mode 100644 index 0000000..a884a20 Binary files /dev/null and b/.gitbook/assets/newplot-29- (2) (1) (1) (2).png differ diff --git a/.gitbook/assets/newplot-29- (2) (1) (1) (3).png b/.gitbook/assets/newplot-29- (2) (1) (1) (3).png new file mode 100644 index 0000000..a884a20 Binary files /dev/null and b/.gitbook/assets/newplot-29- (2) (1) (1) (3).png differ diff --git a/.gitbook/assets/newplot-29- (2) (1) (1) (4).png b/.gitbook/assets/newplot-29- (2) (1) (1) (4).png new file mode 100644 index 0000000..a884a20 Binary files /dev/null and b/.gitbook/assets/newplot-29- (2) (1) (1) (4).png differ diff --git a/.gitbook/assets/newplot-29- (2) (1) (1).png b/.gitbook/assets/newplot-29- (2) (1) (1).png new file mode 100644 index 0000000..a884a20 Binary files /dev/null and b/.gitbook/assets/newplot-29- (2) (1) (1).png differ diff --git a/.gitbook/assets/newplot-29- (2) (1) (2).png b/.gitbook/assets/newplot-29- (2) (1) (2).png new file mode 100644 index 0000000..a884a20 Binary files /dev/null and b/.gitbook/assets/newplot-29- (2) (1) (2).png differ diff --git a/.gitbook/assets/newplot-29- (2) (1) (3).png b/.gitbook/assets/newplot-29- (2) (1) (3).png new file mode 100644 index 0000000..a884a20 Binary files /dev/null and b/.gitbook/assets/newplot-29- (2) (1) (3).png differ diff --git a/.gitbook/assets/newplot-32-.png b/.gitbook/assets/newplot-32-.png deleted file mode 100644 index 4ccee22..0000000 Binary files a/.gitbook/assets/newplot-32-.png and /dev/null differ diff --git a/.gitbook/assets/newplot-5-.png b/.gitbook/assets/newplot-5-.png deleted file mode 100644 index 0c92dc7..0000000 Binary files a/.gitbook/assets/newplot-5-.png and /dev/null differ diff --git a/.gitbook/assets/newplot-9-.png b/.gitbook/assets/newplot-9-.png deleted file mode 100644 index 27d047f..0000000 Binary files a/.gitbook/assets/newplot-9-.png and /dev/null differ diff --git a/.gitbook/assets/screen-shot-2020-08-11-at-12.34.08-am.png b/.gitbook/assets/screen-shot-2020-08-11-at-12.34.08-am.png deleted file mode 100644 index c3bd791..0000000 Binary files a/.gitbook/assets/screen-shot-2020-08-11-at-12.34.08-am.png and /dev/null differ diff --git a/.gitbook/assets/screen-shot-2020-08-11-at-12.38.30-am.png b/.gitbook/assets/screen-shot-2020-08-11-at-12.38.30-am.png deleted file mode 100644 index 3a2cff5..0000000 Binary files a/.gitbook/assets/screen-shot-2020-08-11-at-12.38.30-am.png and /dev/null differ diff --git a/.gitbook/assets/screen-shot-2021-02-14-at-7.22.16-pm.png b/.gitbook/assets/screen-shot-2021-02-14-at-7.22.16-pm.png deleted file mode 100644 index d0e4ab1..0000000 Binary files a/.gitbook/assets/screen-shot-2021-02-14-at-7.22.16-pm.png and /dev/null differ diff --git a/README.md b/README.md index d5001e5..92a7bb7 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ D**anfo.js** is heavily inspired by the [Pandas](https://pandas.pydata.org/panda * Danfo.js is fast and supports[ Tensorflow.js](https://js.tensorflow.org)'s tensors out of the box. This means you can [convert Danfo.js ](api-reference/dataframe/)DataFrames to Tensors, and vice versa. * Easy handling of missing data (represented as `NaN, undefined, or null`) in data -* Size mutability: columns can be inserted/deleted from DataFrame +* Size mutability: columns can be inserted/deleted from DataFrames * Automatic and explicit alignment: objects can be explicitly aligned to a set of labels, or the user can simply ignore the labels and let [`Series`](api-reference/series/), [`DataFrame`](api-reference/dataframe/), etc. automatically align the data for you in computations * Powerful, flexible, [groupby](api-reference/groupby/) functionality to perform split-apply-combine operations on data sets, for both aggregating and transforming data * Make it easy to convert Arrays, JSONs, List or Objects, Tensors, and differently-indexed data structures into DataFrame objects diff --git a/SUMMARY.md b/SUMMARY.md index d9a3ae2..3288ce0 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -84,6 +84,8 @@ * [Series.lt](api-reference/series/series.lt.md) * [Series.iloc](api-reference/series/series.iloc.md) * [Series.loc](api-reference/series/series.loc.md) + * [Series.at](api-reference/series/series.at.md) + * [Series.iat](api-reference/series/series.iat.md) * [Series.ndim](api-reference/series/series.ndim.md) * [Series.shape](api-reference/series/series.shape.md) * [Series.dtype](api-reference/series/series.dtype.md) @@ -145,6 +147,8 @@ * [DataFrame.index](api-reference/dataframe/dataframe.index.md) * [DataFrame.loc](api-reference/dataframe/danfo.dataframe.loc.md) * [DataFrame.iloc](api-reference/dataframe/danfo.dataframe.iloc.md) + * [DataFrame.at](api-reference/dataframe/dataframe.at.md) + * [DataFrame.iat](api-reference/dataframe/dataframe.iat.md) * [DataFrame.head](api-reference/dataframe/danfo.dataframe.head.md) * [DataFrame.tail](api-reference/dataframe/danfo.dataframe.tail.md) * [DataFrame.sample](api-reference/dataframe/danfo.dataframe.sample.md) @@ -199,7 +203,7 @@ * [Line Charts](api-reference/plotting/line-charts.md) * [Customizing your plots](api-reference/plotting/configuring-your-plots.md) * [Groupby](api-reference/groupby/README.md) - * [Groupby.get\_groups](api-reference/groupby/groupby.get\_groups.md) + * [Groupby.getGroups](api-reference/groupby/groupby.getGroups.md) * [Groupby.col](api-reference/groupby/groupby.col.md) * [Groupby.max](api-reference/groupby/groupby.max.md) * [Groupby.min](api-reference/groupby/groupby.min.md) @@ -208,10 +212,10 @@ * [Groupby.std](api-reference/groupby/groupby.std.md) * [Groupby.var](api-reference/groupby/groupby.var.md) * [Groupby.count](api-reference/groupby/groupby.count.md) - * [Groupby.cumsum](api-reference/groupby/groupby.cumsum.md) - * [Groupby.cummax](api-reference/groupby/groupby.cummax.md) - * [Groupby.cummin](api-reference/groupby/groupby.cummin.md) - * [Groupby.cumprod](api-reference/groupby/groupby.cumprod.md) + * [Groupby.cumSum](api-reference/groupby/groupby.cumsum.md) + * [Groupby.cumMax](api-reference/groupby/groupby.cummax.md) + * [Groupby.cumMin](api-reference/groupby/groupby.cummin.md) + * [Groupby.cumProd](api-reference/groupby/groupby.cumprod.md) * [Groupby.agg](api-reference/groupby/groupby.agg.md) * [User Guides](examples/README.md) * [Migrating to the stable version of Danfo.js](examples/migrating-to-the-stable-version-of-danfo.js.md) diff --git a/api-reference-v1-stable/README.md b/api-reference-v1-stable/README.md deleted file mode 100644 index b5d5d28..0000000 --- a/api-reference-v1-stable/README.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -description: >- - This page gives an overview of all public danfo objects, functions and - methods. All classes and functions exposed in danfo.* namespace are public. ---- - -# API reference - -* [General Functions](general-functions/) - * [Data manipulations](general-functions/#data-manipulations) - * [Data Processing/Normalization](general-functions/#data-processing-normalization) - * [Top-level dealing with datetime like](general-functions/#top-level-dealing-with-datetime) -* [Input/output](input-output/) - * [CSV](input-output/#csv) - * [JSON](input-output/#json) -* [Series](series/) - * [Attributes](series/#attributes) - * [Conversion](series/#conversion) - * [Indexing, iteration](series/#indexing-iteration) - * [Binary operator functions](series/#binary-operator-functions) - * [Function application, GroupBy & window](series/#function-application-and-groupby) - * [Computations / descriptive stats](series/#computations-descriptive-stats) - * [Reindexing / selection / label manipulation](series/#reindexing-selection-label-manipulation) - * [Missing data handling](series/#missing-data-handling) - * [Reshaping, sorting](series/#reshaping-sorting) - * [Accessors](series/#accessors) - * [Serialization / IO / conversion](series/#serialization-io-conversion) -* [DataFrame](dataframe/) - * [Attributes ](dataframe/#attributes) - * [Conversion](dataframe/#conversion) - * [Indexing, iteration](dataframe/#indexing-iteration) - * [Binary operator functions](dataframe/#binary-operator-functions) - * [Function application, GroupBy & window](dataframe/#function-application-and-groupby) - * [Computations / descriptive stats](dataframe/#computations-descriptive-stats) - * [Reindexing / selection / label manipulation](dataframe/#reindexing-selection-label-manipulation) - * [Missing data handling](dataframe/#missing-data-handling) - * [Reshaping, sorting, transposing](dataframe/#sorting-and-transposing) - * [Combining / comparing / joining / merging](dataframe/#combining-comparing-joining-merging) - * [Serialization / IO / conversion](dataframe/#serialization-io-conversion) -* [Plotting](plotting/) - * [Line Charts](plotting/line-charts.md) - * [Bar Charts](plotting/bar-charts.md) - * [Scatter Plots](plotting/scatter-plots.md) - * [Histograms](plotting/histograms.md) - * [Pie Charts](plotting/pie-charts.md) - * [Tables](plotting/tables.md) - * [Box Plots](plotting/box-plots.md) - * [Violin Plots](plotting/violin-plots.md) - * [Timeseries Plots](plotting/timeseries-plots.md) -* [GroupBy](https://pandas.pydata.org/pandas-docs/stable/reference/groupby.html) - * [Indexing, iteration](groupby/#indexing-iteration) - * [Function application](groupby/#function-application) - * [Computations / descriptive stats](groupby/#computations-descriptive-stats) - diff --git a/api-reference-v1-stable/configuration-options.md b/api-reference-v1-stable/configuration-options.md deleted file mode 100644 index f4c2136..0000000 --- a/api-reference-v1-stable/configuration-options.md +++ /dev/null @@ -1,128 +0,0 @@ ---- -description: >- - This section describes all user configurable options available on - DataFrame/Series creation. ---- - -# Configuration Options - -On DataFrame/Series creation, a config object can be passed along to configure some internal properties of the created object. The following list shows what options are available and what they do. - -| Parameter | Description | -| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| tableDisplayConfig | **Object**, General table display options. Because we use the table package under the hood to display a table in the console, all [table display configurations](https://www.npmjs.com/package/table) are supported. | -| tableMaxRow | **Number**, the total number of rows to display in the console when the **print** function is called. Defaults to 10 | -| dtypeTestLim | **Number**, the total number of values to test when inferring data type. Defaults to 10 | -| lowMemoryMode |

Boolean, whether to use minimal memory or not. Defaults to false.
Note: There's a slight decrease in speed when low memory mode is set to true.

| - -> See an example of creating DataFrame [in low memory mode](dataframe/creating-a-dataframe.md#creating-a-dataframe-and-specifying-memory-mode) - -## Examples of setting configs - -### Add a DataFrame header - -```javascript - const data = { - "Name": ["Apples", "Mango", "Banana", "Pear"], - "Count": [21, 5, 30, 10], - "Price": [200, 300, 40, 250] - }; -const df = new DataFrame(data, { - config: { - tableDisplayConfig: { - header: { - alignment: 'center', - content: 'THE HEADER\nThis is the table about something', - }, - }, - } -}); -df.print() -``` - -```javascript -╔════════════════════════════════════════════════════════════════════════╗ -║ THE HEADER ║ -║ This is the table about something ║ -╟────────────┬───────────────────┬───────────────────┬───────────────────╢ -║ │ Name │ Count │ Price ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ Apples │ 21 │ 200 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ Mango │ 5 │ 300 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ Banana │ 30 │ 40 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ Pear │ 10 │ 250 ║ -╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -### Configure column size and display format of DataFrame - -```javascript -const data = { - "Name": ["Apples", "Mango", "Banana", "Pear"], - "Count": [21, 5, 30, 10], - "Price": [200, 300, 40, 250] -}; -const df = new DataFrame(data, { - config: { - tableDisplayConfig: { - header: { - alignment: 'center', - content: 'THE HEADER\nThis is the table about something', - }, - columns: [ - { alignment: 'left' }, - { alignment: 'center', width: 20 }, - { alignment: 'right' }, - { alignment: 'justify' } - ], - }, - } -}); -df.print() -``` - -```javascript -╔══════════════════════════════════════════╗ -║ THE HEADER ║ -║ This is the table about something ║ -╟───┬──────────────────────┬───────┬───────╢ -║ │ Name │ Count │ Price ║ -╟───┼──────────────────────┼───────┼───────╢ -║ 0 │ Apples │ 21 │ 200 ║ -╟───┼──────────────────────┼───────┼───────╢ -║ 1 │ Mango │ 5 │ 300 ║ -╟───┼──────────────────────┼───────┼───────╢ -║ 2 │ Banana │ 30 │ 40 ║ -╟───┼──────────────────────┼───────┼───────╢ -║ 3 │ Pear │ 10 │ 250 ║ -╚═══╧══════════════════════╧═══════╧═══════╝ -``` - -### Configure the number of rows displayed when **print** is called - -```javascript -const data = { - "Name": ["Apples", "Mango", "Banana", "Pear"], - "Count": [21, 5, 30, 10], - "Price": [200, 300, 40, 250], - -}; -const df = new DataFrame(data, { - config: { - tableMaxColInConsole: 6, - tableMaxRow: 1 - } -}); -df.print() -``` - -``` -╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Name │ Count │ Price ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ Apples │ 21 │ 200 ║ -╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` diff --git a/api-reference-v1-stable/dataframe/README.md b/api-reference-v1-stable/dataframe/README.md deleted file mode 100644 index d48a28d..0000000 --- a/api-reference-v1-stable/dataframe/README.md +++ /dev/null @@ -1,145 +0,0 @@ ---- -description: Two-dimensional, size-mutable, potentially heterogeneous tabular data. ---- - -# Dataframe - -> `DataFrame`(data, {\ -> **columns:** \[ Array ],\ -> **dtypes:** \[ Array ], **** \ -> **index:** \[Array], \ -> **options**: Object}) - -### Attributes - -| [`DataFrame.index`](dataframe.index.md) | The index (row labels) of the DataFrame. | -| ------------------------------------------------ | ---------------------------------------- | -| [`DataFrame.columns`](danfo.dataframe.column.md) | The column labels of the DataFrame. | - -| [`DataFrame.ctypes`](dataframe.dtypes.md) | Return the data types in the DataFrame. | -| -------------------------------------------------------- | ---------------------------------------------------------------------- | -| [`DataFrame.select_dtypes`](dataframe.select\_dtypes.md) | Return a subset of the DataFrame’s columns based on the column dtypes. | -| [`DataFrame.values`](dataframe.values.md) | Return a Numpy representation of the DataFrame. | -| [`DataFrame.axes`](dataframe.axes.md) | Return a Object representing the axes of the DataFrame. | -| [`DataFrame.ndim`](dataframe.ndim.md) | Return an int representing the number of axes / array dimensions. | -| [`DataFrame.size`](broken-reference) | Return an int representing the number of elements in this object. | -| [`DataFrame.shape`](dataframe.shape.md) | Return a tuple representing the dimensionality of the DataFrame. | - -### Conversion - -| [`DataFrame.astype`](dataframe.astype.md) | Cast a pandas object to a specified dtype `dtype`. | -| ------------------------------------------- | -------------------------------------------------- | -| [`DataFrame.copy`](danfo.dataframe.copy.md) | Make a copy of this object’s indices and data. | - -### Indexing, iteration - -| [`DataFrame.head`](danfo.dataframe.head.md) | Return the first n rows | -| --------------------------------------------- | ------------------------------------------------------------------ | -| [`DataFrame.loc`](danfo.dataframe.loc.md) | Access a group of rows and columns by label(s) or a boolean array. | -| [`DataFrame.iloc`](danfo.dataframe.iloc.md) | Purely integer-location based indexing for selection by position. | -| [`DataFrame.tail`](danfo.dataframe.tail.md) | Return the last n rows. | -| [`DataFrame.query`](danfo.dataframe.query.md) | Query the columns of a DataFrame with a boolean expression. | - -### Binary operator functions - -| [`DataFrame.add`](danfo.dataframe.add.md) | Get Addition of dataframe and other, element-wise (binary operator add). | -| ----------------------------------------- | --------------------------------------------------------------------------------------- | -| [`DataFrame.sub`](danfo.dataframe.sub.md) | Get Subtraction of dataframe and other, element-wise (binary operator sub). | -| [`DataFrame.mul`](danfo.dataframe.mul.md) | Get Multiplication of dataframe and other, element-wise (binary operator mul). | -| [`DataFrame.div`](danfo.dataframe.div.md) | Get Floating division of dataframe and other, element-wise (binary operator truediv). | -| [`DataFrame.mod`](danfo.dataframe.mod.md) | Get Modulo of dataframe and other, element-wise (binary operator mod). | -| [`DataFrame.pow`](danfo.dataframe.pow.md) | Get Exponential power of dataframe and other, element-wise (binary operator pow). | -| [`DataFrame.lt`](broken-reference) | Get Less than of dataframe and other, element-wise (binary operator lt). | -| [`DataFrame.gt`](danfo.dataframe.gt.md) | Get Greater than of dataframe and other, element-wise (binary operator gt). | -| [`DataFrame.le`](danfo.dataframe.le.md) | Get Less than or equal to of dataframe and other, element-wise (binary operator le). | -| [`DataFrame.ge`](broken-reference) | Get Greater than or equal to of dataframe and other, element-wise (binary operator ge). | -| [`DataFrame.ne`](danfo.dataframe.ne.md) | Get Not equal to of dataframe and other, element-wise (binary operator ne). | -| [`DataFrame.eq`](danfo.dataframe.eq.md) | Get Equal to of dataframe and other, element-wise (binary operator eq). | - -### Function application & GroupBy - -| [`DataFrame.apply`](danfo.dataframe.apply.md) | Apply a function along an axis of the DataFrame. | -| --------------------------------------------- | --------------------------------------------------------- | -| [`DataFrame.groupby`](../groupby/) | Group DataFrame using a mapper or by a Series of columns. | -| [`DataFrame.map`](../series/series.map.md) | Map a function on Object along an axis to DataFrame | - -### Computations / descriptive stats - -| [`DataFrame.abs`](danfo.dataframe.abs.md) | Return a Series/DataFrame with absolute numeric value of each element. | -| --------------------------------------------------- | ---------------------------------------------------------------------- | -| [`DataFrame.corr`](broken-reference) | Compute pairwise correlation of columns, excluding NA/null values. | -| [`DataFrame.count`](danfo.dataframe.count.md) | Count non-NAN cells for each column or row. | -| [`DataFrame.cummax`](danfo.dataframe.cummax.md) | Return cumulative maximum over a DataFrame or Series axis. | -| [`DataFrame.cummin`](danfo.dataframe.cummin.md) | Return cumulative minimum over a DataFrame or Series axis. | -| [`DataFrame.cumprod`](danfo.dataframe.cumprod.md) | Return cumulative product over a DataFrame or Series axis. | -| [`DataFrame.cumsum`](danfo.dataframe.cumsum.md) | Return cumulative sum over a DataFrame or Series axis. | -| [`DataFrame.describe`](danfo.dataframe.describe.md) | Generate descriptive statistics. | -| [`DataFrame.max`](danfo.dataframe.max.md) | Return the maximum of the values for the requested axis. | -| [`DataFrame.mean`](danfo.dataframe.mean.md) | Return the mean of the values for the requested axis. | -| [`DataFrame.median`](danfo.dataframe.median.md) | Return the median of the values for the requested axis. | -| [`DataFrame.min`](danfo.dataframe.min.md) | Return the minimum of the values for the requested axis. | -| [`DataFrame.mode`](../series/series.mode.md) | Get the mode(s) of each element along the selected axis. | -| [`DataFrame.round`](danfo.dataframe.round.md) | Round a DataFrame to a variable number of decimal places. | -| [`DataFrame.sum`](danfo.dataframe.sum.md) | Return the sum of the values for the requested axis. | -| [`DataFrame.std`](danfo.dataframe.std.md) | Return sample standard deviation over requested axis. | -| [`DataFrame.var`](danfo.dataframe.var.md) | Return unbiased variance over requested axis. | -| [`DataFrame.nunique`](broken-reference) | Count distinct observations over requested axis. | - -### Reindexing / selection / label manipulation - -| | | -| ---------------------------------------------------- | ------------------------------------------------------- | -| [`DataFrame.drop`](dataframe.drop.md) | Drop specified labels from rows or columns. | -| [`DataFrame.head`](danfo.dataframe.head.md) | Return the first n rows. | -| [`DataFrame.rename`](dataframe.rename.md) | Alter axes labels. | -| [`DataFrame.reset_index`](dataframe.reset\_index.md) | Reset the index of a DataFrame | -| [`DataFrame.sample`](danfo.dataframe.sample.md) | Return a random sample of items from an axis of object. | -| [`DataFrame.set_index`](dataframe.set\_index.md) | Set the DataFrame index using existing columns. | -| [`DataFrame.tail`](danfo.dataframe.tail.md) | Return the last n rows. | - -### Missing data handling - -| | | -| ------------------------------------------------- | ------------------------------------------- | -| [`DataFrame.dropna`](danfo.dataframe.dropna.md) | Remove missing values. | -| [`DataFrame.fillna`](danfo.dataframe.fillna.md) | Fill NaN values with specified values | -| [`DataFrame.isna`](danfo.dataframe.isna.md) | Detect missing values. | -| [`DataFrame.replace`](danfo.dataframe.replace.md) | Replace values given in replace with value. | - -### Sorting & transposing - -| | | -| ---------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | -| [`DataFrame.sort_values`](dataframe.sort\_values.md) | Sort by the values along either axis. | -| [`DataFrame.T`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.T.html#pandas.DataFrame.T) | Return transpose of DataFrame | - -### Combining / comparing / joining / merging - -| | | -| ---------------------------------------------------------- | ------------------------------------------------------------------- | -| [`DataFrame.addColumn`](danfo.dataframe.addcolumn.md) | Add new columns to a DataFrame. | -| [`DataFrame.concat`](../general-functions/danfo.concat.md) | Concatenate DataFrames together. | -| [`DataFrame.merge`](../general-functions/danfo.merge.md) | Merge DataFrame or named Series objects with a database-style join. | - -### Plotting - -`Series.plot` is both a callable method and a namespace attribute for specific plotting methods of the form `Series.plot.`. - -| | | -| -------------------------------------------------------- | ------------------------------------------------------------- | -| [DataFrame.plot.bar](../plotting/bar-charts.md) | Vertical bar plot. | -| [`DataFrame.plot.box`](../plotting/box-plots.md) | Make a box plot of the DataFrame columns. | -| [`DataFrame.plot.violin`](../plotting/box-plots.md) | Make a violin plot of the DataFrame columns. | -| [`DataFrame.plot.hist`](../plotting/histograms.md) | Draw one histogram of the DataFrame’s columns. | -| [`DataFrame.plot.scatter`](../plotting/scatter-plots.md) | Generate Kernel Density Estimate plot using Gaussian kernels. | -| [`DataFrame.plot.line`](../plotting/line-charts.md) | Plot Series or DataFrame as lines. | -| [`DataFrame.plot.pie`](../plotting/pie-charts.md) | Generate a pie plot. | -| [`Timeseries Plots`](../plotting/timeseries-plots.md) | Time series plots | -| [`Table`](../plotting/tables.md) | Display Series as Interactive table in Div | - -### Serialization / IO / conversion - -| | | -| -------------------------------------------- | ---------------------------------------------------- | -| [`DataFrame.to_csv`](dataframe.to\_csv.md) | Write object to a comma-separated values (csv) file. | -| [`DataFrame.to_json`](dataframe.to\_json.md) | Convert the object to a JSON string. | diff --git a/api-reference-v1-stable/dataframe/creating-a-dataframe.md b/api-reference-v1-stable/dataframe/creating-a-dataframe.md deleted file mode 100644 index 0228131..0000000 --- a/api-reference-v1-stable/dataframe/creating-a-dataframe.md +++ /dev/null @@ -1,355 +0,0 @@ ---- -description: Creates a DataFrame object from flat structure ---- - -# Creating a DataFrame - -new danfo.**DataFrame**\(data, options\) - - - - - - - - - - - - - - - - - - - - - -
ParametersTypeDescription
data2D Array, 2D Tensor, JSON object.Flat data structure to load into DataFrame
optionsObject -

Optional configuration object. Supported properties are: -
-

-

index: Array of numeric or string names for subseting array. If - not specified, indexes are auto-generated. -
-

-

columns: Array of column names. If not specified, column names are - auto generated. -
-

-

dtypes: Array of data types for each the column. If not specified, - dtypes are/is inferred. -
-

-

config: General configuration object for extending or setting NDframe - behavior. See full options here

-
- -In order to create a DataFrame, you new to call the new Keyword and pass in a flat data structure. In the following examples, we show you how to create DataFrames by specifying different config options. - -### Creating a `DataFrame` from a JSON object: - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -json_data = [{ A: 0.4612, B: 4.28283, C: -1.509, D: -1.1352 }, - { A: 0.5112, B: -0.22863, C: -3.39059, D: 1.1632 }, - { A: 0.6911, B: -0.82863, C: -1.5059, D: 2.1352 }, - { A: 0.4692, B: -1.28863, C: 4.5059, D: 4.1632 }] - -df = new dfd.DataFrame(json_data) -df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -```markup - - - - - - - - Document - - - - - - - - -``` -{% endtab %} -{% endtabs %} - -### Creating a `DataFrame` from an array of array - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let arr = [[12, 34, 2.2, 2], [30, 30, 2.1, 7]] -let df = new dfd.DataFrame(arr, {columns: ["A", "B", "C", "D"]}) -df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -```markup - - - - - - - - Document - - - - - - - - -``` -{% endtab %} -{% endtabs %} - -```text -╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C │ D ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 12 │ 34 │ 2.2 │ 2 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 30 │ 30 │ 2.1 │ 7 ║ -╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -### Creating a `DataFrame` from a 2D tensor - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") -const tf = require("@tensorflow/tfjs-node") - - -let tensor_arr = tf.tensor2d([[12, 34, 2.2, 2], [30, 30, 2.1, 7]]) -let df = new dfd.DataFrame(tensor_arr, {columns: ["A", "B", "C", "D"]}) -df.print() -df.ctypes.print() -``` -{% endtab %} - -{% tab title="Browser" %} -```markup - - - - - - - - Document - - - - - - - - -``` -{% endtab %} -{% endtabs %} - -```text -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C │ D ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 12 │ 34 │ 2.20000004768... │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 30 │ 30 │ 2.09999990463... │ 7 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ A │ int32 ║ -╟───┼──────────────────────╢ -║ B │ int32 ║ -╟───┼──────────────────────╢ -║ C │ float32 ║ -╟───┼──────────────────────╢ -║ D │ int32 ║ -╚═══╧══════════════════════╝ -``` - -### Creating a `DataFrame` from an object - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -dates = new dfd.date_range({ start: '2017-01-01', end: "2020-01-01", period: 4, freq: "Y" }) - -console.log(dates); - -obj_data = {'A': dates, - 'B': ["bval1", "bval2", "bval3", "bval4"], - 'C': [10, 20, 30, 40], - 'D': [1.2, 3.45, 60.1, 45], - 'E': ["test", "train", "test", "train"] - } - -df = new dfd.DataFrame(obj_data) -df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -```markup - - - - - - - - Document - - - - - - - - -``` -{% endtab %} -{% endtabs %} - -```text -//output in console -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C │ D │ E ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 1/1/2017, 1:0... │ bval1 │ 10 │ 1.2 │ test ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1/1/2018, 1:0... │ bval2 │ 20 │ 3.45 │ train ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 1/1/2019, 1:0... │ bval3 │ 30 │ 60.1 │ test ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 1/1/2020, 1:0... │ bval4 │ 40 │ 45 │ train ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -### Creating a `DataFrame` and specifying index, dtypes, columns - -You can create a DataFrame and specify options like index, column names, dtypes as well as configuration options like display, memory mode etc. - -> Note: Specifing dtypes, column names and index on DataFrame creation makes the process slightly faster. - -{% tabs %} -{% tab title="Node" %} -```javascript -import { DataFrame } from "danfojs" - -let data1 = [[1, 2.3, 3, 4, 5, "girl"], [30, 40.1, 39, 89, 78, "boy"]]; -let index = ["a", "b"]; -let columns = ["col1", "col2", "col3", "col4", "col5", "col6"] -let dtypes = ["int32", "float32", "int32", "int32", "int32", "string"] - -let df = new DataFrame(data1, { index, columns, dtypes }); -df.print() -``` -{% endtab %} -{% endtabs %} - -```text -╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ col1 │ col2 │ col3 │ col4 │ col5 │ col6 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ a │ 1 │ 2.3 │ 3 │ 4 │ 5 │ girl ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ b │ 30 │ 40.1 │ 39 │ 89 │ 78 │ boy ║ -╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -### Creating a `DataFrame` and specifying memory mode - -To use less space on DataFrame creation, you can set the low memory mode as demonstrated below: - -```javascript -import { DataFrame } from "danfojs" - -let data1 = [[1, 2.3, 3, 4, 5, "girl"], [30, 40.1, 39, 89, 78, "boy"]]; - -let df = new DataFrame(data1, { - config: { lowMemoryMode: true } -}); -df.print() -``` - -{% hint style="info" %} -**Note**: In low memory mode, less space is used by the DataFrame. The drawback is that some operations especially the ones involving column data become slightly slower. -{% endhint %} - -For loading flat files like CSV, EXCEL and, JSON into DataFrames, see this [page](../input-output/) - diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.abs.md b/api-reference-v1-stable/dataframe/danfo.dataframe.abs.md deleted file mode 100644 index 8504222..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.abs.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -description: Return a DataFrame with the absolute numeric value of each element. ---- - -# DataFrame.abs - -danfo.DataFrame.**sum**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L454)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | -------------------------------------------------------------------------------------------------- | ------------------ | -| options | Object | **inplace:** Boolean indicating whether to perform the operation inplace or not. Defaults to false | { inplace: false } | - -**Returns:** - - **** return **Series** - -## **Examples** - -The abs function only works on numeric columns and will throw an error if string columns are found in the DataFrame. - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") -let data = {"A": [-20.1, 30, 47.3, -20], - "B": [34, -4, 5, 6], - "C": [20, -20, 30, -40]} - -let df = new dfd.DataFrame(data) - -df.print() - -let df_abs = df.abs() -df_abs.abs().print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ -20.1 │ 34 │ 20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 30 │ -4 │ -20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 47.3 │ 5 │ 30 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ -20 │ 6 │ -40 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - -//after applying abs function - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 20.1 │ 34 │ 20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 30 │ 4 │ 20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 47.3 │ 5 │ 30 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 20 │ 6 │ 40 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.add.md b/api-reference-v1-stable/dataframe/danfo.dataframe.add.md deleted file mode 100644 index 925a3cd..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.add.md +++ /dev/null @@ -1,246 +0,0 @@ ---- -description: Get Addition of DataFrame and other, element-wise (binary operator add). ---- - -# DataFrame.add - -danfo.DataFrame.**add**(other, option) \[[source](https://github.com/opensource9ja/danfojs/blob/fe56860b0a303d218d60ba71dee6abf594401556/danfojs/src/core/frame.js#L347)] - -| Parameters | Type | Description | Default | -| ---------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- | -| other | DataFrame, Series, Array or Scalar | Object to add with | | -| option | Object |

{

axis: 0 for row, 1 for column.

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

}

| { axis: 1, inplace: false } | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -### Addition of **scalar to** DataFrame along default axis 1 - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24] -} -let df = new dfd.DataFrame(data) - -let df_new = df.add(2) - -df_new.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ 12 │ 25 ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ 47 │ 22 ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ 58 │ 12 ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ 12 │ 26 ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Addition of **Series to** DataFrame along axis 0 - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Col1": [1, 4, 5, 1], - "Col2": [3, 2, 0, 4] -} - -let df = new dfd.DataFrame(data) -let sf = new dfd.Series([4, 5]) - -let df_new = df.add(sf, { axis: 1 }) - -df_new.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ 5 │ 8 ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ 8 │ 7 ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ 9 │ 5 ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ 5 │ 9 ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Addition of **** DataFrame to a DataFrame - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs") - -let data = {"Col1": [1, 4, 5, 0], - "Col2": [2, 0, 1, 4]} - -let data2 = {"new_col1": [1, 5, 20, 10], - "new_Col2": [20, 2, 1, 2]} - -let df = new dfd.DataFrame(data) -let df2 = new dfd.DataFrame(data2) - -let df_new = df.add(df2) - -df_new.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ 2 │ 22 ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ 9 │ 2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ 25 │ 2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ 10 │ 6 ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Addition of **** Array to DataFrame along axis 0 - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24] -} - -let df = new dfd.DataFrame(data) -let val = [2, 2, 2, 2] - -let df_new = df.add(val, { axis: 0 }) - -df_new.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ 12 │ 25 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ 47 │ 22 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ 58 │ 12 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ 12 │ 26 ║ -╚════════════╧═══════════════════╧═══════════════════╝ - -``` -{% endtab %} -{% endtabs %} - -### Addition works inplace - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24] -} - -let df = new dfd.DataFrame(data) -let val = [2, 2, 2, 2] - -df.add(val, { axis: 0, inplace: true }) - -df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ 12 │ 25 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ 47 │ 22 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ 58 │ 12 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ 12 │ 26 ║ -╚════════════╧═══════════════════╧═══════════════════╝ - -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.addcolumn.md b/api-reference-v1-stable/dataframe/danfo.dataframe.addcolumn.md deleted file mode 100644 index ef0ecc9..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.addcolumn.md +++ /dev/null @@ -1,118 +0,0 @@ ---- -description: Add new column to a DataFrame ---- - -# DataFrame.addColumn - -danfo.DataFrame.**addColumn**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L1083)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -| options | Object |

{column : str, name of the column to add

values: Series, Array of new values to add
inplace: Default to false.

}

| | - -**Returns:** - -## **Examples** - -## **Add Array as a new column to DataFrame** - -New columns get added at the end of the DataFrame, and this happens so returns nothing, - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") -let data = {"A": [30, 1, 2, 3], - "B": [34, 4, 5, 6], - "C": [20, 20, 30, 40]} - -let df = new dfd.DataFrame(data) -df.print() - -let new_col = [1, 2, 3, 4] -df.addColumn({ "column": "D", "values": new_col, inplace: true }); - -df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 30 │ 34 │ 20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1 │ 4 │ 20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 2 │ 5 │ 30 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 3 │ 6 │ 40 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (4,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C │ D ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 30 │ 34 │ 20 │ 1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1 │ 4 │ 20 │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 2 │ 5 │ 30 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 3 │ 6 │ 40 │ 4 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -## **Add Series as a new column to DataFrame** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") -let data = {"A": [30, 1, 2, 3], - "B": [34, 4, 5, 6], - "C": [20, 20, 30, 40]} - -let df = new dfd.DataFrame(data) -let s = new dfd.Series([1, 2, 3, 4]) -df.addColumn({ "column": "D", "values": s, inplace: true }); - -df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C │ D ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 30 │ 34 │ 20 │ 1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1 │ 4 │ 20 │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 2 │ 5 │ 30 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 3 │ 6 │ 40 │ 4 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.apply.md b/api-reference-v1-stable/dataframe/danfo.dataframe.apply.md deleted file mode 100644 index de42294..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.apply.md +++ /dev/null @@ -1,106 +0,0 @@ ---- -description: Apply a function to each element or along a specified axis of a DataFrame. ---- - -# DataFrame.apply - -danfo.DataFrame.**apply**(callable, options) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L1566)] - -| Parameters | Type | Description | Default | -| ---------- | -------- | --------------------------------------------------------------------- | --------- | -| callable | Function | Function to apply to each column or row | | -| options | Object | **axis**: 0 or 1. If 0, compute the power column-wise, if 1, row-wise | {axis: 1} | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -### Apply a function along default axis 1 (columns) - -{% hint style="info" %} -Note that the specified function passed to `apply` will be called with an array of the values across the specified axis. -{% endhint %} - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = [[1, 2, 3], [4, 5, 6], [20, 30, 40], [39, 89, 78]] -let cols = ["A", "B", "C"] -let df = new dfd.DataFrame(data, { columns: cols }) - -function sum_vals(col) { - return col.reduce((a, b) => a + b, 0); -} - -let df_new = df.apply(sum_vals, { axis: 1 }) -df_new.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═════╗ -║ A │ 64 ║ -╟───┼─────╢ -║ B │ 126 ║ -╟───┼─────╢ -║ C │ 127 ║ -╚═══╧═════╝ -``` -{% endtab %} -{% endtabs %} - -### Apply a function along axis 0 (row) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = [[1, 2, 3], [4, 5, 6], [20, 30, 40], [39, 89, 78]] -let cols = ["A", "B", "C"] -let df = new dfd.DataFrame(data, { columns: cols }) - -function sum_vals(col) { - return col.reduce((a, b) => a + b, 0); -} - -let df_new = df.apply(sum_vals, { axis: 0 }) -df_new.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═════╗ -║ 0 │ 6 ║ -╟───┼─────╢ -║ 1 │ 15 ║ -╟───┼─────╢ -║ 2 │ 90 ║ -╟───┼─────╢ -║ 3 │ 206 ║ -╚═══╧═════╝ - -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.column.md b/api-reference-v1-stable/dataframe/danfo.dataframe.column.md deleted file mode 100644 index 7d963a2..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.column.md +++ /dev/null @@ -1,72 +0,0 @@ ---- -description: Return the elements of the specified column in the DataFrame ---- - -# DataFrame.column - -danfo.DataFrame.**column**(column) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L1217)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ------------------------------------- | ------- | -| column | String | The name of a column in the DataFrame | | - -**Returns:** - - **** return **Series** - -## **Examples** - -## **Select a single column from a DataFrame** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") -let data = { "Name": ["Apples", "App", "Banana", undefined], - "Count": [NaN, 5, NaN, 10] , - "Price": [200, 300, 40, 250] } - -let df = new dfd.DataFrame(data) - -df.column("Name").print() - -//Alternatively, you can retrieve columns by using the object property -df['Name'].print() //produces the same result as above - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════╗ -║ 0 │ Apples ║ -╟───┼───────────╢ -║ 1 │ App ║ -╟───┼───────────╢ -║ 2 │ Banana ║ -╟───┼───────────╢ -║ 3 │ undefined ║ -╚═══╧═══════════╝ - -╔═══╤═══════════╗ -║ 0 │ Apples ║ -╟───┼───────────╢ -║ 1 │ App ║ -╟───┼───────────╢ -║ 2 │ Banana ║ -╟───┼───────────╢ -║ 3 │ undefined ║ -╚═══╧═══════════╝ - -``` -{% endtab %} -{% endtabs %} - -To select more than one column with specific rows, you can use any of the following: [DataFrame.loc](danfo.dataframe.loc.md), [DataFrame.iloc](danfo.dataframe.iloc.md) or [DataFrame.query](danfo.dataframe.query.md) diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.copy.md b/api-reference-v1-stable/dataframe/danfo.dataframe.copy.md deleted file mode 100644 index 188179d..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.copy.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -description: Makes a new copy of the DataFrame ---- - -# DataFrame.copy - -danfo.DataFrame.**copy**() \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L940)] - -**Returns:** - - **** return **new DataFrame** - -## **Examples** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") -let data = {"A": [-20.1, 30, 47.3, -20], - "B": [34, -4, 5, 6], - "C": [20, -20, 30, -40]} -let df = new dfd.DataFrame(data) -let new_df = df.copy() -new_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ -20.1 │ 34 │ 20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 30 │ -4 │ -20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 47.3 │ 5 │ 30 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ -20 │ 6 │ -40 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.count.md b/api-reference-v1-stable/dataframe/danfo.dataframe.count.md deleted file mode 100644 index 637cbf4..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.count.md +++ /dev/null @@ -1,100 +0,0 @@ ---- -description: >- - Count non-NaN cells for each column or row. The values NaN and undefined are - considered NaN ---- - -# DataFrame.count - -danfo.DataFrame.**count**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L454)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ----------------------------------------------------------------------------------- | ----------- | -| options | Object | **axis:** 0 or 1. If 0, compute the mean column-wise, if 1, row-wise. Defaults to 1 | { axis: 1 } | - -**Returns:** - - **** return **Series** - -## **Examples** - -## Count Non-NaN values along default axis 1 (column) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "Name": ["Apples", "Mango", "Banana", undefined], - "Count": [NaN, 5, NaN, 10], - "Price": [200, 300, 40, 250] } - -let df = new dfd.DataFrame(data) -df.count().print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══════╤══════════════════════╗ -║ │ 0 ║ -╟───────┼──────────────────────╢ -║ Name │ 3 ║ -╟───────┼──────────────────────╢ -║ Count │ 2 ║ -╟───────┼──────────────────────╢ -║ Price │ 4 ║ -╚═══════╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -## Count Non-NaN values along row axis (0) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "Name": ["Apples", "Mango", "Banana", undefined], - "Count": [NaN, 5, NaN, 10], - "Price": [200, 300, 40, 250] } - -let df = new dfd.DataFrame(data) -df.count({axis: 0}).print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 2 ║ -╟───┼──────────────────────╢ -║ 1 │ 3 ║ -╟───┼──────────────────────╢ -║ 2 │ 2 ║ -╟───┼──────────────────────╢ -║ 3 │ 2 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -## - diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.cummax.md b/api-reference-v1-stable/dataframe/danfo.dataframe.cummax.md deleted file mode 100644 index fb69bb5..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.cummax.md +++ /dev/null @@ -1,99 +0,0 @@ ---- -description: Return cumulative maximum over a DataFrame or Series axis. ---- - -# DataFrame.cummax - -danfo.DataFrame.**cummax**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L706)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- | -| options | Object |

axis: 0 for row and 1 for column

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

| {axis: 1, inplace: false} | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -## Cumulative maximum of elements along default axis (row) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -data = [[11, 20, 3], [1, 15, 6], [2, 30, 40], [2, 89, 78]] -cols = ["A", "B", "C"] - -let df = new dfd.DataFrame(data, { columns: cols }) -let new_df = df.cummax({ axis: 0 }) - -new_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 11 │ 20 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 11 │ 20 │ 6 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 11 │ 30 │ 40 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 11 │ 89 │ 78 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -## Cumulative maximum of elements along column axis (1) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -data = [[11, 20, 3], [1, 15, 6], [2, 30, 40], [2, 89, 78]] -cols = ["A", "B", "C"] - -let df = new dfd.DataFrame(data, { columns: cols }) -let new_df = df.cummax({ axis: 1 }) - -new_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 11 │ 20 │ 20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1 │ 15 │ 15 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 2 │ 30 │ 40 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 2 │ 89 │ 89 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.cummin.md b/api-reference-v1-stable/dataframe/danfo.dataframe.cummin.md deleted file mode 100644 index be026a6..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.cummin.md +++ /dev/null @@ -1,99 +0,0 @@ ---- -description: Return cumulative minimum over a DataFrame or Series axis. ---- - -# DataFrame.cummin - -danfo.DataFrame.**cummin**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L706)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- | -| options | Object |

axis: 0 for row and 1 for column

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

| {axis: 1, inplace: false} | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -## Cumulative minimum of elements along default axis (row) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -data = [[11, 20, 3], [1, 15, 6], [2, 30, 40], [2, 89, 78]] -cols = ["A", "B", "C"] - -let df = new dfd.DataFrame(data, { columns: cols }) -let new_df = df.cummin({ axis: 0 }) - -new_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 11 │ 20 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1 │ 15 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 1 │ 15 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 1 │ 15 │ 3 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -## Cumulative minimum of elements along column axis (1) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -data = [[11, 20, 3], [1, 15, 6], [2, 30, 40], [2, 89, 78]] -cols = ["A", "B", "C"] - -let df = new dfd.DataFrame(data, { columns: cols }) -let new_df = df.cummin({ axis: 1 }) - -new_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 11 │ 11 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1 │ 1 │ 1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 2 │ 2 │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 2 │ 2 │ 2 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.cumprod.md b/api-reference-v1-stable/dataframe/danfo.dataframe.cumprod.md deleted file mode 100644 index 06ad53a..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.cumprod.md +++ /dev/null @@ -1,99 +0,0 @@ ---- -description: Return cumulative product over a DataFrame or Series axis. ---- - -# DataFrame.cumprod - -danfo.DataFrame.**cumprod**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L706)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- | -| options | Object |

axis: 0 for row and 1 for column

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

| {axis: 1, inplace: false} | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -## Cumulative product of elements along default axis (row) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -data = [[1, 2, 3], [1, 5, 6], [2, 30, 40], [2, 89, 78]] -cols = ["A", "B", "C"] - -let df = new dfd.DataFrame(data, { columns: cols }) -let new_df = df.cumprod() - -new_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 1 │ 2 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1 │ 10 │ 18 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 2 │ 300 │ 720 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 4 │ 26700 │ 56160 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -## Cumulative product of elements along column axis (1) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -data = [[1, 2, 3], [1, 5, 6], [2, 30, 40], [2, 89, 78]] -cols = ["A", "B", "C"] - -let df = new dfd.DataFrame(data, { columns: cols }) -let new_df = df.cumprod({axis: 1}) - -new_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 1 │ 2 │ 6 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1 │ 5 │ 30 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 2 │ 60 │ 2400 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 2 │ 178 │ 13884 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.cumsum.md b/api-reference-v1-stable/dataframe/danfo.dataframe.cumsum.md deleted file mode 100644 index 07be896..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.cumsum.md +++ /dev/null @@ -1,99 +0,0 @@ ---- -description: Return cumulative sum over a DataFrame or Series axis. ---- - -# DataFrame.cumsum - -danfo.DataFrame.**cumsum**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L706)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- | -| options | Object |

axis: 0 for row and 1 for column

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

| {axis: 1, inplace: false} | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -## Cumulative sum of elements along default axis (row) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -data = [[11, 20, 3], [1, 15, 6], [2, 30, 40], [2, 89, 78]] -cols = ["A", "B", "C"] - -let df = new dfd.DataFrame(data, { columns: cols }) -let new_df = df.cumsum({ axis: 0 }) - -new_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 11 │ 20 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 12 │ 35 │ 9 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 14 │ 65 │ 49 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 16 │ 154 │ 127 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -## Cumulative sum of elements along column axis (1) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -data = [[11, 20, 3], [1, 15, 6], [2, 30, 40], [2, 89, 78]] -cols = ["A", "B", "C"] - -let df = new dfd.DataFrame(data, { columns: cols }) -let new_df = df.cumsum({ axis: 1 }) - -new_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 11 │ 31 │ 34 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1 │ 16 │ 22 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 2 │ 32 │ 72 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 2 │ 91 │ 169 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.describe.md b/api-reference-v1-stable/dataframe/danfo.dataframe.describe.md deleted file mode 100644 index 0540873..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.describe.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -description: >- - Generate descriptive statistics for each numeric column. Numeric columns are - of type Int and float. ---- - -# DataFrame.describe - -danfo.DataFrame.**describe**() \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L821)] - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -Descriptive statistics include those that summarize the central tendency, dispersion and shape of a dataset’s distribution, excluding `NaN` values. - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") -let data = [[0, 2, 4, "a"], [360, 180, 360, "b"], [2, 4, 6, "c"]] -let col_names = ["col1", "col2", "col3", "col4"] -let df = new dfd.DataFrame(data, {columns: col_names}) - -df.describe().print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ col1 │ col2 │ col3 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ count │ 3 │ 3 │ 3 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ mean │ 120.66666666666… │ 62 │ 123.33333333333… ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ std │ 207.27115895206… │ 102.19589032832… │ 204.961785055979 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ min │ 0 │ 2 │ 4 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ median │ 2 │ 4 │ 6 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ max │ 360 │ 180 │ 360 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ variance │ 42961.333333333… │ 10444 │ 42009.333333333… ║ -╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -## diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.div.md b/api-reference-v1-stable/dataframe/danfo.dataframe.div.md deleted file mode 100644 index c98c66e..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.div.md +++ /dev/null @@ -1,254 +0,0 @@ ---- -description: >- - Get Float division of DataFrame and other, element-wise (binary operator - truediv). ---- - -# DataFrame.div - -danfo.DataFrame.div(other, option) \[[source](https://github.com/opensource9ja/danfojs/blob/fe56860b0a303d218d60ba71dee6abf594401556/danfojs/src/core/frame.js#L347)] - -| Parameters | Type | Description | Default | -| ---------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- | -| other | DataFrame, Series, Array or Scalar | Object to add with | | -| option | Object |

{

axis: 0 for row, 1 for column.

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

}

| { axis: 1, inplace: false } | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -### Division of **scalar with** DataFrame along default axis 1 - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24] -} -let df = new dfd.DataFrame(data) - -let df_new = df.div(2) - -df_new.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ 5 │ 11.5 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ 22.5 │ 10 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ 28 │ 5 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ 5 │ 12 ║ -╚════════════╧═══════════════════╧═══════════════════╝ - -``` -{% endtab %} -{% endtabs %} - -### Division of **Series with** DataFrame along axis 0 - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Col1": [1, 4, 5, 1], - "Col2": [3, 2, 0, 4] -} - -let df = new dfd.DataFrame(data) -let sf = new dfd.Series([4, 5]) - -let df_new = df.div(sf, { axis: 1 }) - -df_new.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ 0.25 │ 0.6000000238418… ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1 │ 0.4000000059604… ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ 1.25 │ 0 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ 0.25 │ 0.8000000119209… ║ -╚════════════╧═══════════════════╧═══════════════════╝ - - -``` -{% endtab %} -{% endtabs %} - -### Division of **** DataFrame **with** a DataFrame - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs") - -let data = {"Col1": [1, 4, 5, 0], - "Col2": [2, 0, 1, 4]} - -let data2 = {"new_col1": [1, 5, 20, 10], - "new_Col2": [20, 2, 1, 2]} - -let df = new dfd.DataFrame(data) -let df2 = new dfd.DataFrame(data2) - -let df_new = df.div(df2) - -df_new.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ 1 │ 0.1000000014901… ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ 0.8000000119209… │ 0 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ 0.25 │ 1 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ 0 │ 2 ║ -╚════════════╧═══════════════════╧═══════════════════╝ - - -``` -{% endtab %} -{% endtabs %} - -### Division of **** Array **with** DataFrame along axis 0 - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24] -} - -let df = new dfd.DataFrame(data) -let val = [2, 2, 2, 2] - -let df_new = df.div(val, { axis: 0 }) - -df_new.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ 5 │ 11.5 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ 22.5 │ 10 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ 28 │ 5 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ 5 │ 12 ║ -╚════════════╧═══════════════════╧═══════════════════╝ - -``` -{% endtab %} -{% endtabs %} - -### Division works inplace - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24] -} - -let df = new dfd.DataFrame(data) -let val = [2, 2, 2, 2] - -df.div(val, { axis: 0, inplace: true }) - -df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ 5 │ 11.5 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ 22.5 │ 10 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ 28 │ 5 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ 5 │ 12 ║ -╚════════════╧═══════════════════╧═══════════════════╝ - - -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.dropna.md b/api-reference-v1-stable/dataframe/danfo.dataframe.dropna.md deleted file mode 100644 index 429bcbe..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.dropna.md +++ /dev/null @@ -1,96 +0,0 @@ ---- -description: Remove missing values (NaNs, undefined, null) for DataFrame ---- - -# DataFrame.dropna - -danfo.DataFrame.**dropna**(axis, options) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L1430)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ----------------------------------------------------------------------------------------------------------------------------- | -------------------- | -| axis | Int | 0 or 1. If 0, drop columns with NaNs, if 1, drop rows with NaNs | 1 | -| options | Object |

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

| {**inplace:** false} | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -### Drop rows (axis=0) with missing values - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = [[1, 2, 3], [NaN, 5, 6], [NaN, 30, 40], [39, undefined, 78]] -let cols = ["A", "B", "C"] -let df = new dfd.DataFrame(data, { columns: cols }) - -df.print() - -let df_drop = df.dropna(0) -df_drop.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 1 │ 2 │ 3 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Drop columns (axis=1) with missing values - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = [[1, 2, 3], [NaN, 5, 6], [NaN, 30, 40], [39, undefined, 78]] -let cols = ["A", "B", "C"] -let df = new dfd.DataFrame(data, { columns: cols }) - -df.print() - -df.dropna({axis: 1, inplace: true}) -df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╗ -║ │ C ║ -╟───┼───────────────────╢ -║ 0 │ 3 ║ -╟───┼───────────────────╢ -║ 1 │ 6 ║ -╟───┼───────────────────╢ -║ 2 │ 40 ║ -╟───┼───────────────────╢ -║ 3 │ 78 ║ -╚═══╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.eq.md b/api-reference-v1-stable/dataframe/danfo.dataframe.eq.md deleted file mode 100644 index 5f3cf2a..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.eq.md +++ /dev/null @@ -1,190 +0,0 @@ ---- -description: Get Equal to of DataFrame and other, element-wise (binary operator eq). ---- - -# DataFrame.eq - -danfo.DataFrame.eq(other, option) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L1566)] - -| Parameters | Type | Description | Default | -| ---------- | -------------------------------- | ----------------------------------------------------------- | --------- | -| other | DataFrame, Series, Array, Scalar | Data structure, or array-like object to compare against | | -| option | Object | **axis**: 0 or 1. If 0, add column-wise, if 1, add row-wise | {axis: 1} | - -**Returns:** - -**** - -## **Examples** - -### Comparing **** DataFrame with a scalar value: - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24]} -let df = new dfd.DataFrame(data) - -let df_rep = df.eq(20) - -df_rep.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ false │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ false │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ false │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ false │ false ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Comparing **** DataFrame with a Series along the column axis: - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24]} -let df = new dfd.DataFrame(data) -let sf = new dfd.Series([10,40]) - -let df_rep = df.eq(sf, {axis:1}) - -df_rep.print() - - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```javascript -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ true │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ false │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ false │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ true │ false ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Comparing **** DataFrame with a DataFrame - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24]} -let data2 = {"new_col1": [10, 45, 200, 10], - "new_Col2": [230, 200, 110, 24]} - -let df = new dfd.DataFrame(data) -let df2 = new dfd.DataFrame(data2) - -let df_rep = df.eq(df2) - -df_rep.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```javascript -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ true │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ true │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ false │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ true │ true ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Comparing **** DataFrame with a JavaScript Array - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24]} -let df = new dfd.DataFrame(data) -let val = [10,40] - -let df_rep = df.eq(val, {axis:1}) - -df_rep.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```javascript -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ true │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ false │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ false │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ true │ false ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.fillna.md b/api-reference-v1-stable/dataframe/danfo.dataframe.fillna.md deleted file mode 100644 index 2ddb860..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.fillna.md +++ /dev/null @@ -1,178 +0,0 @@ ---- -description: >- - Fill NaN/undefined values using the specified method. Detect missing values - for an array-like object. ---- - -# DataFrame.fillna - -danfo.DataFrame.**fillna**(values, options) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L1235)] - -| Parameters | Type | Description | Default | -| ---------- | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | -| values | Array \| Scalar | The list of value(s) to use for replacement. | | -| options | Object |

{columns:Array of column name(s) to fill. If undefined fill all columns

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

}

| {inplace: false} | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -### Fill missing values in specified columns with specified values - -Missing values are NaN, undefined or null values - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Name": ["Apples", "Mango", "Banana", undefined], - "Count": [NaN, 5, NaN, 10], - "Price": [200, 300, 40, 250] -} - -let df = new dfd.DataFrame(data) -df.print() - -let values = ["Apples", df["Count"].mean()] -let df_filled = df.fillna(values, { columns: ["Name", "Count"] }) -df_filled.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -//Before filling -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Name │ Count │ Price ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ Apples │ NaN │ 200 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ Mango │ 5 │ 300 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ Banana │ NaN │ 40 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ NaN │ 10 │ 250 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - //After filling - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Name │ Count │ Price ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ Apples │ 7.5 │ 200 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ Mango │ 5 │ 300 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ Banana │ 7.5 │ 40 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ Apples │ 10 │ 250 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝═╝ -``` -{% endtab %} -{% endtabs %} - -### Fill all columns with NaNs with a specified value - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Name": ["Apples", "Mango", "Banana", undefined], - "Count": [NaN, 5, NaN, 10], - "Price": [200, 300, 40, 250] -} - -let df = new dfd.DataFrame(data) -let df_filled = df.fillna("Apples") - -df_filled.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Name │ Count │ Price ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ Apples │ Apples │ 200 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ Mango │ 5 │ 300 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ Banana │ Apples │ 40 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ Apples │ 10 │ 250 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Fill NaNs inplace - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") -let data = { - "Name": ["Apples", "Mango", "Banana", undefined], - "Count": [NaN, 5, NaN, 10], - "Price": [200, 300, 40, 250] -} - -let df = new dfd.DataFrame(data) -let values = ["Apples", df["Count"].mean()] -df.fillna(values, { - columns: ["Name", "Count"], - inplace: true -}) -df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Name │ Count │ Price ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ Apples │ Apples │ 200 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ Mango │ 5 │ 300 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ Banana │ Apples │ 40 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ Apples │ 10 │ 250 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.ge.md b/api-reference-v1-stable/dataframe/danfo.dataframe.ge.md deleted file mode 100644 index 8e5401b..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.ge.md +++ /dev/null @@ -1,195 +0,0 @@ ---- -description: >- - Get Greater or Equal to of DataFrame and other, element-wise (binary operator - eq). ---- - -# DataFrame.ge - -danfo.DataFrame.ge(other, option) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L1566)] - -| Parameters | Type | Description | Default | -| ---------- | -------------------------------- | ----------------------------------------------------------- | --------- | -| other | DataFrame, Series, Array, Scalar | Data structure, or array-like object to compare against | | -| option | Object | **axis**: 0 or 1. If 0, add column-wise, if 1, add row-wise | {axis: 1} | - -**Returns:** - - **DataFrame** - -## **Examples** - -### Comparing **** DataFrame with a scalar value: - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24]} - -let df = new dfd.DataFrame(data) - -let df_rep = df.ge(20) - -df_rep.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ false │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ true │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ true │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ false │ true ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Comparing **** DataFrame with a Series along the column axis: - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24]} - -let df = new dfd.DataFrame(data) -let sf = new dfd.Series([10,40]) - -let df_rep = df.ge(sf, {axis:1}) - -df_rep.print() - - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```javascript -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ true │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ true │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ true │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ true │ false ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Comparing **** DataFrame with a DataFrame - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24]} -let data2 = {"new_col1": [10, 45, 200, 10], - "new_Col2": [230, 200, 110, 24]} - -let df = new dfd.DataFrame(data) -let df2 = new dfd.DataFrame(data2) - -let df_rep = df.ge(df2) - -df_rep.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```javascript -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ true │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ true │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ false │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ true │ true ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Comparing **** DataFrame with a JavaScript Array - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24]} -let df = new dfd.DataFrame(data) -let val = [10,40] - -let df_rep = df.ge(val, {axis:1}) - -df_rep.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```javascript -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ true │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ true │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ true │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ true │ false ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.groupby.md b/api-reference-v1-stable/dataframe/danfo.dataframe.groupby.md deleted file mode 100644 index e7d084f..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.groupby.md +++ /dev/null @@ -1,148 +0,0 @@ ---- -description: Group DataFrame using a mapper or by a Series of columns. ---- - -# DataFrame.groupby - -danfo.DataFrame.**groupby**(columns) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L1142)] - -| Parameters | Type | Description | Default | -| ---------- | ----- | ----------------------------------------------------- | ------- | -| columns | Array | The names of a column(s) in the DataFrame to group by | | - -**Returns:** - - **** return **DataFrame.groups** - -## **Examples** - -## **Groupby a single column from a DataFrame** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = [["Pear", 2, 3], ["Pear", 5, 6], ["Apple", 30, 40], ["Apple", 89, 78]] -let cols = ["A", "B", "C"] - -let df = new dfd.DataFrame(data, { columns: cols }) -let group_df = df.groupby(["A"]) -console.log(group_df) - -//GroupBy Object -GroupBy { - key_col: [ 'A' ], - col_dict: { Pear: [ [Array], [Array] ], Apple: [ [Array], [Array] ] }, - data: [ - [ 'Pear', 2, 3 ], - [ 'Pear', 5, 6 ], - [ 'Apple', 30, 40 ], - [ 'Apple', 89, 78 ] - ], - column_name: [ 'A', 'B', 'C' ], - data_tensors: { - Pear: DataFrame { - '$isSeries': false, - '$config': [Configs], - '$data': [Array], - '$dataIncolumnFormat': [Array], - '$index': [Array], - '$dtypes': [Array], - '$columns': [Array] - }, - Apple: DataFrame { - '$isSeries': false, - '$config': [Configs], - '$data': [Array], - '$dataIncolumnFormat': [Array], - ... - '$columns': [Array] - } - }, - col_dtype: [ 'string' ] -} -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -A groupby operation will return a GroupBy class object. You can apply any of the following operation on the groupby result: - -1. [count](danfo.dataframe.count.md) -2. [sum](danfo.dataframe.sum.md) -3. [std](danfo.dataframe.std.md) -4. [var](danfo.dataframe.var.md) -5. [mean](danfo.dataframe.mean.md) -6. [cumsum](danfo.dataframe.cumsum.md) -7. [cummax](danfo.dataframe.cummax.md) -8. [cumprod](danfo.dataframe.cumprod.md) -9. [cummin](danfo.dataframe.cummin.md) -10. [max](danfo.dataframe.max.md) -11. [min](danfo.dataframe.min.md) - -## Example of Groupby and apply a sum function - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = [["Pear", 2, 3], ["Pear", 5, 6], ["Apple", 30, 40], ["Apple", 89, 78]] -let cols = ["A", "B", "C"] -let df = new dfd.DataFrame(data, { columns: cols }) -let group_df = df.groupby(["A"]).sum() - -group_df.print() - -``` -{% endtab %} -{% endtabs %} - -``` -╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B_sum │ C_sum ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ Pear │ 7 │ 9 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ Apple │ 119 │ 118 ║ -╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -## **Groupby a two columns from a DataFrame** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = [["Pear", 2, 3], ["Pear", 2, 6], ["Apple", 30, 40], ["Apple", 89, 78]] -let cols = ["A", "B", "C"] -let df = new dfd.DataFrame(data, { columns: cols }) -let group_df = df.groupby(["A", "B"]).sum() - -group_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -``` -╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_sum ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ Pear │ 2 │ 9 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ Apple │ 30 │ 40 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ Apple │ 89 │ 78 ║ -╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.gt.md b/api-reference-v1-stable/dataframe/danfo.dataframe.gt.md deleted file mode 100644 index ec3f7ba..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.gt.md +++ /dev/null @@ -1,191 +0,0 @@ ---- -description: Get Greater than of DataFrame and other, element-wise (binary operator eq). ---- - -# DataFrame.gt - -danfo.DataFrame.g**t**(other, option) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L1566)] - -| Parameters | Type | Description | Default | -| ---------- | -------------------------------- | ----------------------------------------------------------- | --------- | -| other | DataFrame, Series, Array, Scalar | Data structure, or array-like object to compare against | | -| option | Object | **axis**: 0 or 1. If 0, add column-wise, if 1, add row-wise | {axis: 1} | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -### Comparing **** DataFrame with a scalar value: - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24]} -let df = new dfd.DataFrame(data) - -let df_rep = df.gt(20) - -df_rep.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ false │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ true │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ true │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ false │ true ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Comparing **** DataFrame with a Series along the column axis: - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24]} -let df = new dfd.DataFrame(data) -let sf = new dfd.Series([10,40]) - -let df_rep = df.gt(sf, {axis:1}) - -df_rep.print() - - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ false │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ true │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ true │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ false │ false ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Comparing **** DataFrame with a DataFrame - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24]} -let data2 = {"new_col1": [10, 45, 200, 10], - "new_Col2": [230, 200, 110, 24]} - -let df = new dfd.DataFrame(data) -let df2 = new dfd.DataFrame(data2) - -let df_rep = df.gt(df2) - -df_rep.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ false │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ false │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ false │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ false │ false ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Comparing **** DataFrame with a JavaScript Array - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24]} -let df = new dfd.DataFrame(data) -let val = [10,40] - -let df_rep = df.gt(val, axis=1) - -df_rep.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ false │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ true │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ true │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ false │ false ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.head.md b/api-reference-v1-stable/dataframe/danfo.dataframe.head.md deleted file mode 100644 index 3fe62c4..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.head.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -description: Returns the first n rows of the DataFrame based on position. ---- - -# DataFrame.head - -danfo.DataFrame.**head**(rows) \[[source](https://github.com/opensource9ja/danfojs/blob/fe56860b0a303d218d60ba71dee6abf594401556/danfojs/src/core/frame.js#L292)] - -| Parameters | Type | Description | Default | -| ---------- | ---- | ---------------------------- | ------- | -| rows | Int | The number of rows to return | 5 | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "Name": ["Apples", "Mango", "Banana", "Pear"], - "Count": [21, 5, 30, 10], - "Price": [200, 300, 40, 250] } - -let df = new dfd.DataFrame(data) -let s_df = df.head(2) -s_df.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Name │ Count │ Price ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ Apples │ 21 │ 200 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ Mango │ 5 │ 300 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.iloc.md b/api-reference-v1-stable/dataframe/danfo.dataframe.iloc.md deleted file mode 100644 index ffd7e25..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.iloc.md +++ /dev/null @@ -1,331 +0,0 @@ ---- -description: Purely integer-location based indexing for selection by position. ---- - -# DataFrame.iloc - -danfo.DataFrame.**iloc**(args) \[[source](https://github.com/opensource9ja/danfojs/blob/fe56860b0a303d218d60ba71dee6abf594401556/danfojs/src/core/frame.js#L254)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -| args | Object |

{

rows: Array, index of row position

columns: Array, index of position along columns

}

| | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -`.iloc()` is primarily integer position based (from `0` to `length-1` of the axis). - -Allowed inputs are: - -* An integer, e.g. `5`. -* A list or array of integers, e.g. `[4, 3, 0]`. -* A string slice object with ints, e.g. `"1:7"` -* A boolean array. - -_**Note:** only the start index is included._ - -`.iloc` will raise`IndexError` if a requested indexer is out-of-bounds. - -### **Indexing specific rows by index and return all columns** - -If the row's index is specified and the columns are not, then it returns all columns and just the specified rows. - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "Name": ["Apples", "Mango", "Banana", "Pear"], - "Count": [21, 5, 30, 10], - "Price": [200, 300, 40, 250] } - -let df = new dfd.DataFrame(data) -let sub_df = df.iloc({rows: [0,1,3]}) -sub_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Name │ Count │ Price ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ Apples │ 21 │ 200 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ Mango │ 5 │ 300 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ Pear │ 10 │ 250 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### **Index by a slice of row and return all columns** - -The [**iloc**](danfo.dataframe.iloc.md) function also accepts string slices of the form \[start: end], e.g "\[1: 3]". This will return all values between index position 1 and 3. The end index is not included. - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "Name": ["Apples", "Mango", "Banana", "Pear"], - "Count": [21, 5, 30, 10], - "Price": [200, 300, 40, 250] } - -let df = new dfd.DataFrame(data) -let sub_df = df.iloc({rows: ["1:3"]}) -sub_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Name │ Count │ Price ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ Mango │ 5 │ 300 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ Banana │ 30 │ 40 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### **Index by a slice of column and return all rows** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "Name": ["Apples", "Mango", "Banana", "Pear"], - "Count": [21, 5, 30, 10], - "Price": [200, 300, 40, 250] } - -let df = new dfd.DataFrame(data) -df.print() - -let sub_df = df.iloc({columns: ["1:"]}) -sub_df.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Name │ Count │ Price ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ Apples │ 21 │ 200 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ Mango │ 5 │ 300 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ Banana │ 30 │ 40 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ Pear │ 10 │ 250 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (4,2) - -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Count │ Price ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ 21 │ 200 ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ 5 │ 300 ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ 30 │ 40 ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ 10 │ 250 ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Indexing both axes by the specified index - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "Name": ["Apples", "Mango", "Banana", "Pear"], - "Count": [21, 5, 30, 10], - "Price": [200, 300, 40, 250] } - -let df = new dfd.DataFrame(data) -let sub_df = df.iloc({rows: [0,3], columns: [1,2]}) -sub_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Name │ Count │ Price ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ Apples │ 21 │ 200 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ Mango │ 5 │ 300 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ Banana │ 30 │ 40 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ Pear │ 10 │ 250 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - //after indexing - -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Count │ Price ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ 21 │ 200 ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ 10 │ 250 ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Indexing both axes by slices - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "Name": ["Apples", "Mango", "Banana", "Pear"], - "Count": [21, 5, 30, 10], - "Price": [200, 300, 40, 250] } - -let df = new dfd.DataFrame(data) -df.print() - -let sub_df = df.iloc({rows: ["2:3"], columns: ["1:2"]}) -sub_df.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Name │ Count │ Price ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ Apples │ 21 │ 200 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ Mango │ 5 │ 300 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ Banana │ 30 │ 40 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ Pear │ 10 │ 250 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - - -╔═══╤═══════════════════╗ -║ │ Count ║ -╟───┼───────────────────╢ -║ 2 │ 30 ║ -╚═══╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### More default slicing behavior - -If you specify a slice start position, **iloc** automatically returns all values after that position. For instance: - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "Name": ["Apples", "Mango", "Banana", "Pear"], - "Count": [21, 5, 30, 10], - "Price": [200, 300, 40, 250] } - -let df = new dfd.DataFrame(data) -df.print() - -let sub_df = df.iloc({rows: ["2:"], columns: ["1:"]}) -sub_df.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Name │ Count │ Price ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ Apples │ 21 │ 200 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ Mango │ 5 │ 300 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ Banana │ 30 │ 40 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ Pear │ 10 │ 250 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (2,2) - -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Count │ Price ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ 30 │ 40 ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ 10 │ 250 ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.isna.md b/api-reference-v1-stable/dataframe/danfo.dataframe.isna.md deleted file mode 100644 index 830bda5..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.isna.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -description: >- - Return a boolean same-sized object indicating if the values are NaN. - NaN/undefined values gets mapped to true values, and everything else gets - mapped to false values. ---- - -# DataFrame.isna - -danfo.DataFrame.**isna**(kwargs) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L1350)] - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = [[1, 2, 3], [NaN, 5, 6], [NaN, 30, 40], [39, undefined, 78]] -let cols = ["A", "B", "C"] -let df = new dfd.DataFrame(data, { columns: cols }) - -df.isna().print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ false │ false │ false ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ true │ false │ false ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ true │ false │ false ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ false │ true │ false ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.it.md b/api-reference-v1-stable/dataframe/danfo.dataframe.it.md deleted file mode 100644 index 3759197..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.it.md +++ /dev/null @@ -1,194 +0,0 @@ ---- -description: Get Less than of DataFrame and other, element-wise (binary operator eq). ---- - -# DataFrame.It - -danfo.DataFrame.l**t**(other, option) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L1566)] - -| Parameters | Type | Description | Default | -| ---------- | -------------------------------- | ----------------------------------------------------------- | --------- | -| other | DataFrame, Series, Array, Scalar | Data structure, or array-like object to compare against | | -| option | Object | **axis**: 0 or 1. If 0, add column-wise, if 1, add row-wise | {axis: 1} | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -### Comparing **** DataFrame with a scalar value: - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24]} -let df = new dfd.DataFrame(data) - -let df_rep = df.lt(20) - -df_rep.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ true │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ false │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ false │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ true │ false ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Comparing **** DataFrame with a Series along the column axis: - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24] -} -let df = new dfd.DataFrame(data) -let sf = new dfd.Series([10, 40]) - -let df_rep = df.lt(sf, { axis: 1 }) - -df_rep.print() - - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ false │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ false │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ false │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ false │ true ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Comparing **** DataFrame with a DataFrame - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24]} -let data2 = {"new_col1": [10, 45, 200, 10], - "new_Col2": [230, 200, 110, 24]} - -let df = new dfd.DataFrame(data) -let df2 = new dfd.DataFrame(data2) - -let df_rep = df.lt(df2) - -df_rep.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ false │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ false │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ true │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ false │ false ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Comparing **** DataFrame with an Array - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24]} - -let df = new dfd.DataFrame(data) -let val = [10,40] - -let df_rep = df.lt(val, axis=1) - -df_rep.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ false │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ false │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ false │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ false │ true ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.le.md b/api-reference-v1-stable/dataframe/danfo.dataframe.le.md deleted file mode 100644 index 31ce3f7..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.le.md +++ /dev/null @@ -1,194 +0,0 @@ ---- -description: >- - Get Less than or Equal to of DataFrame and other, element-wise (binary - operator eq). ---- - -# DataFrame.le - -danfo.DataFrame.le(other, option) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L1566)] - -| Parameters | Type | Description | Default | -| ---------- | -------------------------------- | ----------------------------------------------------------- | --------- | -| other | DataFrame, Series, Array, Scalar | Data structure, or array-like object to compare against | | -| option | Object | **axis**: 0 or 1. If 0, add column-wise, if 1, add row-wise | {axis: 1} | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -### Comparing **** DataFrame with a scalar value: - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24]} - -let df = new dfd.DataFrame(data) - -let df_rep = df.le(20) - -df_rep.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ true │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ false │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ false │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ true │ false ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Comparing **** DataFrame with a Series along the column axis: - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24]} - -let df = new dfd.DataFrame(data) -let sf = new dfd.Series([10,40]) - -let df_rep = df.le(sf, {axis:1}) - -df_rep.print() - - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ true │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ false │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ false │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ true │ true ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Comparing **** DataFrame with a DataFrame - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24]} -let data2 = {"new_col1": [10, 45, 200, 10], - "new_Col2": [230, 200, 110, 24]} - -let df = new dfd.DataFrame(data) -let df2 = new dfd.DataFrame(data2) - -let df_rep = df.le(df2) - -df_rep.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```javascript -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ true │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ true │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ true │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ true │ true ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Comparing **** DataFrame with an Array - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24]} -let df = new dfd.DataFrame(data) -let val = [10,40] - -let df_rep = df.le(val, {axis:1}) - -df_rep.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```javascript -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ true │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ false │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ false │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ true │ true ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.loc.md b/api-reference-v1-stable/dataframe/danfo.dataframe.loc.md deleted file mode 100644 index abdcdd9..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.loc.md +++ /dev/null @@ -1,367 +0,0 @@ ---- -description: Access a group of rows and columns by label(s) ---- - -# DataFrame.loc - -danfo.DataFrame.**loc**(args) \[[source](https://github.com/opensource9ja/danfojs/blob/cf5c7ae3a009458e61eedd18d9c9b5b6b10d5276/danfojs/src/core/frame.js#L125)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------- | -| args | Object |

{

rows: Array, labels, Boolean mask of row index

columns: Array, labels of column names

}

| | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -`.loc()` is label position based-from `0` to `length-1` of the row axis. - -Allowed inputs for are: - -* An integer, e.g. `"r1"`. -* A list or array of integers, e.g. `["a", "b", "d"]`. -* A boolean mask. E.g \[ true, false, false ] -* A string slice object with ints, e.g. `[`'`"a":"d"'], ["1:4"]` - -_**Note:** only **** the start label is included, and the end label is ignored._ - -`.loc` will raise a `ValueEror` if a requested label is not found. - -### **Index by specific rows and return all columns** - -If the row's index is specified and the columns are not, then it returns all columns and just the specified rows. - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "Name": ["Apples", "Mango", "Banana", "Pear"], - "Count": [21, 5, 30, 10], - "Price": [200, 300, 40, 250] } - -let df = new dfd.DataFrame(data, {index: ["a", "b", "c", "d"]}) -df.print() -let sub_df = df.loc({rows: ["a", "c"]}) -sub_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Name │ Count │ Price ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ a │ Apples │ 21 │ 200 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ b │ Mango │ 5 │ 300 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ c │ Banana │ 30 │ 40 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ d │ Pear │ 10 │ 250 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (2,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Name │ Count │ Price ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ a │ Apples │ 21 │ 200 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ c │ Banana │ 30 │ 40 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### **Index by a list of column names and return all rows** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "Name": ["Apples", "Mango", "Banana", "Pear"], - "Count": [21, 5, 30, 10], - "Price": [200, 300, 40, 250] } - -let df = new dfd.DataFrame(data, {index: ["a", "b", "c", "d"]}) -df.print() -let sub_df = df.loc({columns: ["Count", "Price"]}) -sub_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Name │ Count │ Price ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ a │ Apples │ 21 │ 200 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ b │ Mango │ 5 │ 300 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ c │ Banana │ 30 │ 40 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ d │ Pear │ 10 │ 250 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - //after indexing - -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Count │ Price ║ -╟───┼───────────────────┼───────────────────╢ -║ a │ 21 │ 200 ║ -╟───┼───────────────────┼───────────────────╢ -║ b │ 5 │ 300 ║ -╟───┼───────────────────┼───────────────────╢ -║ c │ 30 │ 40 ║ -╟───┼───────────────────┼───────────────────╢ -║ d │ 10 │ 250 ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Index both axes by the specified labels - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "Name": ["Apples", "Mango", "Banana", "Pear"], - "Count": [21, 5, 30, 10], - "Price": [200, 300, 40, 250] } - -let df = new dfd.DataFrame(data, { index: ["a", "b", "c", "d"] }) -df.print() -let sub_df = df.loc({ rows: ["c","d"], columns: ["Name", "Price"] }) -sub_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Name │ Count │ Price ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ a │ Apples │ 21 │ 200 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ b │ Mango │ 5 │ 300 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ c │ Banana │ 30 │ 40 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ d │ Pear │ 10 │ 250 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - - -//after slicing - -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Name │ Price ║ -╟───┼───────────────────┼───────────────────╢ -║ c │ Banana │ 40 ║ -╟───┼───────────────────┼───────────────────╢ -║ d │ Pear │ 250 ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -## **Index by a slice of row** - -The **loc** function also accepts string slices of the form \[start: end], e.g **\[\`"a":"c"\`]**. This will return all values from label positions `a` to c. - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "Name": ["Apples", "Mango", "Banana", "Pear"], - "Count": [21, 5, 30, 10], - "Price": [200, 300, 40, 250] } - -let df = new dfd.DataFrame(data, { index: ["a", "b", "c", "d"] }) -df.print() -let sub_df = df.loc({ rows: [`"a":"c"`], columns: ["Name", "Price"] }) -sub_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Name │ Count │ Price ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ a │ Apples │ 21 │ 200 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ b │ Mango │ 5 │ 300 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ c │ Banana │ 30 │ 40 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ d │ Pear │ 10 │ 250 ║ -╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Name │ Price ║ -╟────────────┼───────────────────┼───────────────────╢ -║ a │ Apples │ 200 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ b │ Mango │ 300 ║ -╚════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -{% hint style="info" %} -Note that when using loc with alphabetic slices. We expect you to pass labels in the correct format. That is, string labels must be explicitly quoted. For example, the following loc slice will throw an error:\ -df`.loc({ row: [a:e]}).print()`\ -For the slice above to work, you must quote each slice, e.g:\ -df``.loc({ row: [`"a":"e"`]}).print()``\ -\ -_**Inner**_ _**quotes are not needed for numeric indices!**_ -{% endhint %} - -### Slice DataFrame rows by boolean condition - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Name": ["Apples", "Mango", "Banana", "Pear"], - "Count": [21, 5, 30, 10], - "Price": [200, 300, 40, 250] -} - -let df = new dfd.DataFrame(data, { index: ["a", "b", "c", "d"] }) -let sub_df = df.loc({ rows: df["Count"].gt(6) }) -sub_df.print() -``` -{% endtab %} -{% endtabs %} - -``` -╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Name │ Count │ Price ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ a │ Apples │ 21 │ 200 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ c │ Banana │ 30 │ 40 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ d │ Pear │ 10 │ 250 ║ -╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - - -``` - -### Slice DataFrame rows by multiple boolean conditions - -{% hint style="info" %} -_By design, you can chain as many boolean logic as possible, as long as they resolve to a Boolean array of the same length as the DataFrame._ -{% endhint %} - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Name": ["Apples", "Mango", "Banana", "Pear"], - "Count": [21, 5, 30, 10], - "Price": [200, 300, 40, 250] -} - -let df = new dfd.DataFrame(data, { index: ["a", "b", "c", "d"] }) -let condition = df["Count"].gt(6).and(df["Price"].lt(250)) -let sub_df = df.loc({ rows: condition }) -sub_df.print() -``` -{% endtab %} -{% endtabs %} - -``` -╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Name │ Count │ Price ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ a │ Apples │ 21 │ 200 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ c │ Banana │ 30 │ 40 ║ -╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - -``` - -### Slice DataFrame with boolean mask - -{% hint style="info" %} -_You can index a DataFrame with an array of boolean values as long as they resolve to an array of the same length as the DataFrame._ -{% endhint %} - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Name": ["Apples", "Mango", "Banana", "Pear"], - "Count": [21, 5, 30, 10], - "Price": [200, 300, 40, 250] -} - -let df = new dfd.DataFrame(data, { index: ["a", "b", "c", "d"] }) - -let sub_df = df.loc({ rows: [false, true, true, true] }) -sub_df.print() -``` -{% endtab %} -{% endtabs %} - -``` -╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Name │ Count │ Price ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ b │ Mango │ 5 │ 300 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ c │ Banana │ 30 │ 40 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ d │ Pear │ 10 │ 250 ║ -╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - - -``` diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.max.md b/api-reference-v1-stable/dataframe/danfo.dataframe.max.md deleted file mode 100644 index a5c2119..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.max.md +++ /dev/null @@ -1,118 +0,0 @@ ---- -description: Return the maximum of the values for the requested axis. ---- - -# DataFrame.max - -danfo.DataFrame.**max**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L454)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ----------------------------------------------------------------------------------- | ----------- | -| options | Object | **axis:** 0 or 1. If 0, compute the mean column-wise, if 1, row-wise. Defaults to 1 | { axis: 1 } | - -**Returns:** - - **** return **Series** - -## **Examples** - -## Return the maximum value along default axis 1 (column) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") -data = [[11, 20, 3], [1, 15, 6], [2, 30, 40], [2, 89, 78]] -cols = ["A", "B", "C"] - -df.print() - -let df = new dfd.DataFrame(data) -df.max().print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 11 │ 20 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1 │ 15 │ 6 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 2 │ 30 │ 40 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 2 │ 89 │ 78 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ A │ 11 ║ -╟───┼──────────────────────╢ -║ B │ 89 ║ -╟───┼──────────────────────╢ -║ C │ 78 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -## Return the maximum value along row axis (0) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") -data = [[11, 20, 3], [1, 15, 6], [2, 30, 40], [2, 89, 78]] -cols = ["A", "B", "C"] - -df.print() -let df = new dfd.DataFrame(data) -df.max({axis:0}).print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 11 │ 20 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1 │ 15 │ 6 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 2 │ 30 │ 40 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 2 │ 89 │ 78 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 20 ║ -╟───┼──────────────────────╢ -║ 1 │ 15 ║ -╟───┼──────────────────────╢ -║ 2 │ 40 ║ -╟───┼──────────────────────╢ -║ 3 │ 89 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.mean.md b/api-reference-v1-stable/dataframe/danfo.dataframe.mean.md deleted file mode 100644 index 172cff5..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.mean.md +++ /dev/null @@ -1,120 +0,0 @@ ---- -description: Return the mean of the values for the requested axis. ---- - -# DataFrame.mean - -danfo.DataFrame.**mean**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L454)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ----------------------------------------------------------------------------------- | ----------- | -| options | Object | **axis:** 0 or 1. If 0, compute the mean column-wise, if 1, row-wise. Defaults to 1 | { axis: 1 } | - -**Returns:** - - **** return **Series** - -## **Examples** - -## Computes the mean of values along default axis 1 (column) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -data = [[11, 20, 3], [1, 15, 6], [2, 30, 40], [2, 89, 78]] -cols = ["A", "B", "C"] - -df.print() - -let df = new dfd.DataFrame(data) -df.mean().print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 11 │ 20 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1 │ 15 │ 6 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 2 │ 30 │ 40 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 2 │ 89 │ 78 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ A │ 4 ║ -╟───┼──────────────────────╢ -║ B │ 38.5 ║ -╟───┼──────────────────────╢ -║ C │ 31.75 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -## Computes the mean of values along row axis (0) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = [[11, 20, 3], [1, 15, 6], [2, 30, 40], [2, 89, 78]] -let cols = ["A", "B", "C"] - -df.print() -let df = new dfd.DataFrame(data) -df.mean({ axis: 0 }).print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 11 │ 20 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1 │ 15 │ 6 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 2 │ 30 │ 40 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 2 │ 89 │ 78 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 11.333333015441895 ║ -╟───┼──────────────────────╢ -║ 1 │ 7.333333492279053 ║ -╟───┼──────────────────────╢ -║ 2 │ 24 ║ -╟───┼──────────────────────╢ -║ 3 │ 56.33333206176758 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.median.md b/api-reference-v1-stable/dataframe/danfo.dataframe.median.md deleted file mode 100644 index 3e33583..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.median.md +++ /dev/null @@ -1,120 +0,0 @@ ---- -description: Return the median of the values for the requested axis. ---- - -# DataFrame.median - -danfo.DataFrame.**median**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L454)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ----------------------------------------------------------------------------------- | ----------- | -| options | Object | **axis:** 0 or 1. If 0, compute the mean column-wise, if 1, row-wise. Defaults to 1 | { axis: 1 } | - -**Returns:** - - **** return **Series** - -## **Examples** - -## Calculates the median of values along default axis 1 (column) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -data = [[11, 20, 3], [1, 15, 6], [2, 30, 40], [2, 89, 78]] -cols = ["A", "B", "C"] - -df.print() - -let df = new dfd.DataFrame(data) -df.median().print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 11 │ 20 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1 │ 15 │ 6 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 2 │ 30 │ 40 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 2 │ 89 │ 78 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ A │ 2 ║ -╟───┼──────────────────────╢ -║ B │ 25 ║ -╟───┼──────────────────────╢ -║ C │ 23 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -## Calculates the median of values along row axis (0) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -data = [[11, 20, 3], [1, 15, 6], [2, 30, 40], [2, 89, 78]] -cols = ["A", "B", "C"] - -df.print() -let df = new dfd.DataFrame(data) -df.median({axis:0}).print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 11 │ 20 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1 │ 15 │ 6 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 2 │ 30 │ 40 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 2 │ 89 │ 78 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 11 ║ -╟───┼──────────────────────╢ -║ 1 │ 6 ║ -╟───┼──────────────────────╢ -║ 2 │ 30 ║ -╟───┼──────────────────────╢ -║ 3 │ 78 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.min.md b/api-reference-v1-stable/dataframe/danfo.dataframe.min.md deleted file mode 100644 index 49a13d6..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.min.md +++ /dev/null @@ -1,120 +0,0 @@ ---- -description: Return the minimum of the values for the requested axis. ---- - -# DataFrame.min - -danfo.DataFrame.**min**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L454)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ----------------------------------------------------------------------------------- | ----------- | -| options | Object | **axis:** 0 or 1. If 0, compute the mean column-wise, if 1, row-wise. Defaults to 1 | { axis: 1 } | - -**Returns:** - - **** return **Series** - -## **Examples** - -## Returns the minimum value along default axis 1 (column) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -data = [[11, 20, 3], [1, 15, 6], [2, 30, 40], [2, 89, 78]] -cols = ["A", "B", "C"] - -df.print() - -let df = new dfd.DataFrame(data) -df.min().print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 11 │ 20 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1 │ 15 │ 6 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 2 │ 30 │ 40 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 2 │ 89 │ 78 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ A │ 1 ║ -╟───┼──────────────────────╢ -║ B │ 15 ║ -╟───┼──────────────────────╢ -║ C │ 3 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -## Return the minimum value along row axis (0) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -data = [[11, 20, 3], [1, 15, 6], [2, 30, 40], [2, 89, 78]] -cols = ["A", "B", "C"] - -df.print() -let df = new dfd.DataFrame(data) -df.min({axis: 0}).print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 11 │ 20 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1 │ 15 │ 6 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 2 │ 30 │ 40 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 2 │ 89 │ 78 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 3 ║ -╟───┼──────────────────────╢ -║ 1 │ 1 ║ -╟───┼──────────────────────╢ -║ 2 │ 2 ║ -╟───┼──────────────────────╢ -║ 3 │ 2 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.mod.md b/api-reference-v1-stable/dataframe/danfo.dataframe.mod.md deleted file mode 100644 index 18558e6..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.mod.md +++ /dev/null @@ -1,258 +0,0 @@ ---- -description: Get Modulo of DataFrame and other, element-wise (binary operator mod). ---- - -# DataFrame.mod - -danfo.DataFrame.mod(other, option) \[[source](https://github.com/opensource9ja/danfojs/blob/fe56860b0a303d218d60ba71dee6abf594401556/danfojs/src/core/frame.js#L347)] - -| Parameters | Type | Description | Default | -| ---------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- | -| other | DataFrame, Series, Array or Scalar | Object to add with | | -| option | Object |

{

axis: 0 for row, 1 for column.

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

}

| { axis: 1, inplace: false } | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -### Modulo of **scalar with** DataFrame along default axis 1 - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24] -} -let df = new dfd.DataFrame(data) - -let df_new = df.mod(2) - -df_new.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ 0 │ 1 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1 │ 0 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ 0 │ 0 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ 0 │ 0 ║ -╚════════════╧═══════════════════╧═══════════════════╝ - - - -``` -{% endtab %} -{% endtabs %} - -### Modulo of **Series with** DataFrame along axis 0 - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Col1": [1, 4, 5, 1], - "Col2": [3, 2, 0, 4] -} - -let df = new dfd.DataFrame(data) -let sf = new dfd.Series([4, 5]) - -let df_new = df.mod(sf, { axis: 1 }) - -df_new.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ 1 │ 3 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ 0 │ 2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ 1 │ 0 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ 1 │ 4 ║ -╚════════════╧═══════════════════╧═══════════════════╝ - - - -``` -{% endtab %} -{% endtabs %} - -### Modulo of **** DataFrame with a DataFrame - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs") - -let data = {"Col1": [1, 4, 5, 0], - "Col2": [2, 0, 1, 4]} - -let data2 = {"new_col1": [1, 5, 20, 10], - "new_Col2": [20, 2, 1, 2]} - -let df = new dfd.DataFrame(data) -let df2 = new dfd.DataFrame(data2) - -let df_new = df.mod(df2) - -df_new.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ 0 │ 2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ 4 │ 0 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ 5 │ 0 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ 0 │ 0 ║ -╚════════════╧═══════════════════╧═══════════════════╝ - - - -``` -{% endtab %} -{% endtabs %} - -### Modulo of **** Array with DataFrame along axis 0 - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24] -} - -let df = new dfd.DataFrame(data) -let val = [2, 2, 2, 2] - -let df_new = df.mod(val, { axis: 0 }) - -df_new.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ 0 │ 1 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1 │ 0 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ 0 │ 0 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ 0 │ 0 ║ -╚════════════╧═══════════════════╧═══════════════════╝ - - -``` -{% endtab %} -{% endtabs %} - -### Modulo works inplace - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24] -} - -let df = new dfd.DataFrame(data) -let val = [2, 2, 2, 2] - -df.mod(val, { axis: 0, inplace: true }) - -df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ 0 │ 1 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1 │ 0 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ 0 │ 0 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ 0 │ 0 ║ -╚════════════╧═══════════════════╧═══════════════════╝ - - - -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.mul.md b/api-reference-v1-stable/dataframe/danfo.dataframe.mul.md deleted file mode 100644 index 3303d77..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.mul.md +++ /dev/null @@ -1,252 +0,0 @@ ---- -description: Get Multiplication of dataframe and other, element-wise (binary operator mul). ---- - -# DataFrame.mul - -danfo.DataFrame.mul(other, option) \[[source](https://github.com/opensource9ja/danfojs/blob/fe56860b0a303d218d60ba71dee6abf594401556/danfojs/src/core/frame.js#L347)] - -| Parameters | Type | Description | Default | -| ---------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- | -| other | DataFrame, Series, Array or Scalar | Object to add with | | -| option | Object |

{

axis: 0 for row, 1 for column.

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

}

| { axis: 1, inplace: false } | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -### Multiplication of **scalar to** DataFrame along default axis 1 - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24] -} -let df = new dfd.DataFrame(data) - -let df_new = df.mul(2) - -df_new.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ 20 │ 46 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ 90 │ 40 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ 112 │ 20 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ 20 │ 48 ║ -╚════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Multiplication of **Series to** DataFrame along axis 0 - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Col1": [1, 4, 5, 1], - "Col2": [3, 2, 0, 4] -} - -let df = new dfd.DataFrame(data) -let sf = new dfd.Series([4, 5]) - -let df_new = df.mul(sf, { axis: 1 }) - -df_new.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ 4 │ 15 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ 16 │ 10 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ 20 │ 0 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ 4 │ 20 ║ -╚════════════╧═══════════════════╧═══════════════════╝ - -``` -{% endtab %} -{% endtabs %} - -### Multiplication of **** DataFrame to a DataFrame - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs") - -let data = {"Col1": [1, 4, 5, 0], - "Col2": [2, 0, 1, 4]} - -let data2 = {"new_col1": [1, 5, 20, 10], - "new_Col2": [20, 2, 1, 2]} - -let df = new dfd.DataFrame(data) -let df2 = new dfd.DataFrame(data2) - -let df_new = df.mul(df2) - -df_new.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ 1 │ 40 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ 20 │ 0 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ 100 │ 1 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ 0 │ 8 ║ -╚════════════╧═══════════════════╧═══════════════════╝ - - -``` -{% endtab %} -{% endtabs %} - -### Multiplication of **** Array to DataFrame along axis 0 - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24] -} - -let df = new dfd.DataFrame(data) -let val = [2, 2, 2, 2] - -let df_new = df.mul(val, { axis: 0 }) - -df_new.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ 20 │ 46 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ 90 │ 40 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ 112 │ 20 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ 20 │ 48 ║ -╚════════════╧═══════════════════╧═══════════════════╝ - - - -``` -{% endtab %} -{% endtabs %} - -### Multiplication works inplace - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24] -} - -let df = new dfd.DataFrame(data) -let val = [2, 2, 2, 2] - -df.mul(val, { axis: 0, inplace: true }) - -df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ 20 │ 46 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ 90 │ 40 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ 112 │ 20 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ 20 │ 48 ║ -╚════════════╧═══════════════════╧═══════════════════╝ - - -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.ne.md b/api-reference-v1-stable/dataframe/danfo.dataframe.ne.md deleted file mode 100644 index dd45cf0..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.ne.md +++ /dev/null @@ -1,187 +0,0 @@ ---- -description: Get Not Equal to of DataFrame and other, element-wise (binary operator eq). ---- - -# DataFrame.ne - -danfo.DataFrame.ne(other, option) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L1566)] - -| Parameters | Type | Description | Default | -| ---------- | -------------------------------- | ----------------------------------------------------------- | --------- | -| other | DataFrame, Series, Array, Scalar | Data structure, or array-like object to compare against | | -| option | Object | **axis**: 0 or 1. If 0, add column-wise, if 1, add row-wise | {axis: 1} | - -**Returns:** - -**** - -## **Examples** - -### Comparing **** DataFrame with a scalar value: - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24]} -let df = new dfd.DataFrame(data) - -let df_rep = df.ne(20) - -df_rep.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ true │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ true │ false ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ true │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ true │ true ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Comparing **** DataFrame with a Series along the column axis: - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24]} -let df = new dfd.DataFrame(data) -let sf = new dfd.Series([10,40]) - -let df_rep = df.ne(sf, {axis:1}) - -df_rep.print() - - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ false │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ true │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ true │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ false │ true ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Comparing **** DataFrame with a DataFrame - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24]} -let data2 = {"new_col1": [10, 45, 200, 10], - "new_Col2": [230, 200, 110, 24]} - -let df = new dfd.DataFrame(data) -let df2 = new dfd.DataFrame(data2) - -let df_rep = df.ne(df2) - -df_rep.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ false │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ false │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ true │ true ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ false │ false ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Comparing **** DataFrame with a JavaScript Array - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24]} -let df = new dfd.DataFrame(data) -let val = [10, 40, 30, 20] - -let df_rep = df.le(val) - -df_rep.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ 0 │ 1 │ 2 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ true │ false │ false │ true ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ false │ true │ true │ false ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.pow.md b/api-reference-v1-stable/dataframe/danfo.dataframe.pow.md deleted file mode 100644 index e6f1e6c..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.pow.md +++ /dev/null @@ -1,260 +0,0 @@ ---- -description: >- - Get Exponential power of dataframe and other, element-wise (binary operator - pow). ---- - -# DataFrame.pow - -danfo.DataFrame.pow(other, option) \[[source](https://github.com/opensource9ja/danfojs/blob/fe56860b0a303d218d60ba71dee6abf594401556/danfojs/src/core/frame.js#L347)] - -| Parameters | Type | Description | Default | -| ---------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- | -| other | DataFrame, Series, Array or Scalar | Object to add with | | -| option | Object |

{

axis: 0 for row, 1 for column.

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

}

| { axis: 1, inplace: false } | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -### Exponential of **scalar with** DataFrame along default axis 1 - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24] -} -let df = new dfd.DataFrame(data) - -let df_new = df.pow(2) - -df_new.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ 100 │ 529 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ 2025 │ 400 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ 3136 │ 100 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ 100 │ 576 ║ -╚════════════╧═══════════════════╧═══════════════════╝ - - - -``` -{% endtab %} -{% endtabs %} - -### Exponential of **Series with** DataFrame along axis 0 - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Col1": [1, 4, 5, 1], - "Col2": [3, 2, 0, 4] -} - -let df = new dfd.DataFrame(data) -let sf = new dfd.Series([4, 5]) - -let df_new = df.pow(sf, { axis: 1 }) - -df_new.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ 1 │ 243 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ 256 │ 32 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ 625 │ 0 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ 1 │ 1024 ║ -╚════════════╧═══════════════════╧═══════════════════╝ - - - -``` -{% endtab %} -{% endtabs %} - -### Exponential of **** DataFrame with a DataFrame - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs") - -let data = {"Col1": [1, 4, 5, 0], - "Col2": [2, 0, 1, 4]} - -let data2 = {"new_col1": [1, 5, 20, 10], - "new_Col2": [20, 2, 1, 2]} - -let df = new dfd.DataFrame(data) -let df2 = new dfd.DataFrame(data2) - -let df_new = df.pow(df2) - -df_new.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ 1 │ 1048576 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1024 │ 0 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ 95367433551872 │ 1 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ 0 │ 16 ║ -╚════════════╧═══════════════════╧═══════════════════╝ - - - -``` -{% endtab %} -{% endtabs %} - -### Exponential of **** Array with DataFrame along axis 0 - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24] -} - -let df = new dfd.DataFrame(data) -let val = [2, 2, 2, 2] - -let df_new = df.pow(val, { axis: 0 }) - -df_new.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ 100 │ 529 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ 2025 │ 400 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ 3136 │ 100 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ 100 │ 576 ║ -╚════════════╧═══════════════════╧═══════════════════╝ - - -``` -{% endtab %} -{% endtabs %} - -### Exponential works inplace - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24] -} - -let df = new dfd.DataFrame(data) -let val = [2, 2, 2, 2] - -df.pow(val, { axis: 0, inplace: true }) - -df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ 100 │ 529 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ 2025 │ 400 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ 3136 │ 100 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ 100 │ 576 ║ -╚════════════╧═══════════════════╧═══════════════════╝ - - - -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.query.md b/api-reference-v1-stable/dataframe/danfo.dataframe.query.md deleted file mode 100644 index 129c8e7..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.query.md +++ /dev/null @@ -1,278 +0,0 @@ ---- -description: >- - Query the DataFrame by the result of a logical comparison or boolean mask. - Supports logical operations like (">", "<", ">=", "<=", and. "==") ---- - -# DataFrame.query - -danfo.DataFrame.**query**(kwargs) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L1011)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------- | -| kwargs | Object |

{

condition: A logical boolean mask,

column : str, name of the column

is: Logical operator, one of ">", "<", ">=", "<=", and. "=="

to: Int, Float, Str. Value to compare against,

inplace: boolean. true | false. Whether to perform operation to the original Object or create a new one.

}

| {**inplace**: false} | - -**Returns:** - - **** return **new DataFrame** - -## **Examples** - -## **Query a DataFrame using a boolean mask** - -{% hint style="info" %} -Querying by a boolean condition is supported from v0.3.0 and above. -{% endhint %} - -```javascript -let data = { - "A": ["Ng", "Yu", "Mo", "Ng"], - "B": [34, 4, 5, 6], - "C": [20, 20, 30, 40] -} -let df = new dfd.DataFrame(data) - -let query_df = df.query({ condition: df["B"].gt(5) }) -query_df.print() //after query -``` - -``` -╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 20 │ 30 │ 40 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 39 │ 89 │ 78 ║ -╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -It also supports condition chaining as long as the final boolean mask is the same lenght as the DataFrame rows. For example in the following code, we use multiple chaining conditions: - -```javascript -let data = { - "A": ["Ng", "Yu", "Mo", "Ng"], - "B": [34, 4, 5, 6], - "C": [20, 20, 30, 40] -} -let df = new dfd.DataFrame(data) - -let query_df = df.query({ condition: df["B"].gt(5).and(df["C"].lt(40)) }) -query_df.print() //after query - -//output -╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ Ng │ 34 │ 20 ║ -╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - - -``` - -## **Query a DataFrame using logical operators** - -To query a DataFrame, you can specify the column to use, the logical operator (">", "<", ">=", "<=", and. "=="), and the value to compare against. - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"A": [30, 1, 2, 3], - "B": [34, 4, 5, 6], - "C": [20, 20, 30, 40]} - -let cols = ["A", "B", "C"] -let df = new dfd.DataFrame(data, { columns: cols }) -df.print() //before query - -let query_df = df.query({ "column": "B", "is": ">", "to": 5 }) -query_df.print() //after query -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -//before query -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 1 │ 2 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 4 │ 5 │ 6 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 20 │ 30 │ 40 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 39 │ 89 │ 78 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - -//after query -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 20 │ 30 │ 40 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 39 │ 89 │ 78 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") -let data = {"A": [30, 1, 2, 3], - "B": [34, 4, 5, 6], - "C": [20, 20, 30, 40]} - -let df = new dfd.DataFrame(data) - -df.print() - -let query_df = df.query({ "column": "A", "is": ">", "to": 9 }) -query_df.print() //after query - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 30 │ 34 │ 20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1 │ 4 │ 20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 2 │ 5 │ 30 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 3 │ 6 │ 40 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - -//after query - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 30 │ 34 │ 20 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -## **Query by a string column in a DataFrame** - -The query method also works on string columns. - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") -let data = {"A": ["Ng", "Yu", "Mo", "Ng"], - "B": [34, 4, 5, 6], - "C": [20, 20, 30, 40]} - -let df = new dfd.DataFrame(data) - -df.print() - -let query_df = df.query({ column: "A", is: "==", to: "Ng"}) -query_df.print() //after query - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ Ng │ 34 │ 20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ Yu │ 4 │ 20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ Mo │ 5 │ 30 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ Ng │ 6 │ 40 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - -//after query - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ Ng │ 34 │ 20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ Ng │ 6 │ 40 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -## **Query a DataFrame inplace** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"A": [30, 1, 2, 3], - "B": [34, 4, 5, 6], - "C": [20, 20, 30, 40]} - -let cols = ["A", "B", "C"] -let df = new dfd.DataFrame(data, { columns: cols }) - -df.query({ - column: "B", - is: ">", - to: 5, - inplace: true -}) -df.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 30 │ 34 │ 20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 3 │ 6 │ 40 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.replace.md b/api-reference-v1-stable/dataframe/danfo.dataframe.replace.md deleted file mode 100644 index 82fa16d..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.replace.md +++ /dev/null @@ -1,102 +0,0 @@ ---- -description: Replaces values in a DataFrame with specified values ---- - -# DataFrame.replace - -> danfo.DataFrame.**replace**(oldValue, newValue, options) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L1670)] - -| Parameters | Type | Description | Default | -| ---------- | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------- | -| oldValue | String, boolean, Number | The value you want to replace | | -| newValue | String, boolean, Number | The new value you want to replace the old value with | | -| options | Object |

columns: Array. An array of column names to replace, If not specified, replace all columns.

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

| {inplace: false} | - -**Returns:** - - **** return **DataFrame** - -**** - -## **Examples** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24] -} -let df = new dfd.DataFrame(data) - -let df_rep = df.replace(10, -999, { columns: ["Col1"] }) - -df_rep.print() - - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ -999 │ 23 ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ 45 │ 20 ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ 56 │ 10 ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ -999 │ 24 ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -By not specifying a **** column**,** the **** replace works on all columns **** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = [["A", "A", "A", "B"], ["B", "C", "C", "D"]] -let df = new dfd.DataFrame(data) -//replace value in all column -let df_rep = df.replace("A", "BOY") - -df_rep.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```javascript - -╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ 0 │ 1 │ 2 │ 3 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ BOY │ BOY │ BOY │ B ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ B │ C │ C │ D ║ -╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.round.md b/api-reference-v1-stable/dataframe/danfo.dataframe.round.md deleted file mode 100644 index e12cb52..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.round.md +++ /dev/null @@ -1,128 +0,0 @@ ---- -description: Round elements in a DataFrame to a specified number of decimal places. ---- - -# DataFrame.round - -danfo.DataFrame.**round**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L454)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | -------------------------------------------------------------------------------------------------- | ------------------ | -| dp | Int | Number of decimal places to round to. Defaults to 1 | 1 | -| options | Object | **inplace:** Boolean indicating whether to perform the operation inplace or not. Defaults to false | { inplace: false } | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -## Round elements to 1dp (Default) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -data = [[11.20, 20.1234, 3.567], [1, 15.1, 6.0], [2, 3.09, 40.234]] -cols = ["A", "B", "C"] - -let df = new dfd.DataFrame(data, { columns: cols }) -df.print() - -let new_df = df.round() - -new_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 11.2 │ 20.1234 │ 3.567 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1 │ 15.1 │ 6 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 2 │ 3.09 │ 40.234 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - //after round - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 11.2 │ 20.1 │ 3.6 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1 │ 15.1 │ 6 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 2 │ 3.1 │ 40.2 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -## Round elements to a specified number of decimal places - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -data = [[11.20, 20.1234, 3.567], [1, 15.1, 6.0], [2, 3.09, 40.234]] -cols = ["A", "B", "C"] - -let df = new dfd.DataFrame(data, { columns: cols }) -df.print() - -let new_df = df.round(2) - -new_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 11.2 │ 20.1234 │ 3.567 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1 │ 15.1 │ 6 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 2 │ 3.09 │ 40.234 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - //after round operation - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 11.2 │ 20.12 │ 3.57 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 1 │ 15.1 │ 6 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 2 │ 3.09 │ 40.23 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -## diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.sample.md b/api-reference-v1-stable/dataframe/danfo.dataframe.sample.md deleted file mode 100644 index b8a4c96..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.sample.md +++ /dev/null @@ -1,112 +0,0 @@ ---- -description: Return a random sample of rows from DataFrame. ---- - -# DataFrame.sample - -danfo.DataFrame.**sample**(num, seed) \[[source](https://github.com/opensource9ja/danfojs/blob/fe56860b0a303d218d60ba71dee6abf594401556/danfojs/src/core/frame.js#L314)] - -| Parameters | Type | Description | Default | -| ---------- | ---- | ---------------------------------------------------------------------------------------------------------------------------------- | ------- | -| num | Int | The number of rows to return. Defaults to -1, which shuffles and return all rows. | -1 | -| seed | int | An integer specifying the random seed that will be used to create the distribution. Ensures reproducibility of generated samples. | 1 | - -**Returns:** - - **** return **{Promies} resolves to DataFrame** - -**** - -## Sample a DataFrame randomly - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -async function load_data() { - let data = { - Name: ["Apples", "Mango", "Banana", "Pear"], - Count: [21, 5, 30, 10], - Price: [200, 300, 40, 250], - }; - - let df = new dfd.DataFrame(data); - let s_df = await df.sample(2); - s_df.print(); - -} - -load_data() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Name │ Count │ Price ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ Apples │ 21 │ 200 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ Banana │ 30 │ 40 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -## Sample a DataFrame randomly with seed - -By setting `seed` when using `sample`, you can ensure that the random sampling is reproducible. - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -async function load_data() { - let data = { - Name: ["Apples", "Mango", "Banana", "Pear"], - Count: [21, 5, 30, 10], - Price: [200, 300, 40, 250], - }; - - let df = new dfd.DataFrame(data); - let s_df = await df.sample(3, { seed: 2 }); - s_df.print(); - -} - -load_data() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Name │ Count │ Price ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ Mango │ 5 │ 300 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ Banana │ 30 │ 40 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ Apples │ 21 │ 200 ║ -╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - - -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.std.md b/api-reference-v1-stable/dataframe/danfo.dataframe.std.md deleted file mode 100644 index 1a37e2e..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.std.md +++ /dev/null @@ -1,94 +0,0 @@ ---- -description: Return sample standard deviation over requested axis. ---- - -# DataFrame.std - -danfo.DataFrame.**std**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L454)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ----------------------------------------------------------------------------------- | ----------- | -| options | Object | **axis:** 0 or 1. If 0, compute the mean column-wise, if 1, row-wise. Defaults to 1 | { axis: 1 } | - -**Returns:** - - **** return **Series** - -## **Examples** - -## Calculates the standard deviation of values along default axis 1 (column) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") -data = [[11, 20, 3], [1, 15, 6], [2, 30, 40], [2, 89, 78]] -cols = ["A", "B", "C"] - -let df = new dfd.DataFrame(data) -df.std().print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 4.69041575982343 ║ -╟───┼──────────────────────╢ -║ 1 │ 34.23935357645254 ║ -╟───┼──────────────────────╢ -║ 2 │ 35.103418636936205 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -## Calculates the standard deviation of values along row axis (0) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") -data = [[11, 20, 3], [1, 15, 6], [2, 30, 40], [2, 89, 78]] -cols = ["A", "B", "C"] - -let df = new dfd.DataFrame(data) -df.std({axis:0}).print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 8.504900548115383 ║ -╟───┼──────────────────────╢ -║ 1 │ 7.094598884597588 ║ -╟───┼──────────────────────╢ -║ 2 │ 19.697715603592208 ║ -╟───┼──────────────────────╢ -║ 3 │ 47.37439533475159 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -## - diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.sub.md b/api-reference-v1-stable/dataframe/danfo.dataframe.sub.md deleted file mode 100644 index e36ddcc..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.sub.md +++ /dev/null @@ -1,250 +0,0 @@ ---- -description: Get Subtraction of dataframe and other, element-wise (binary operator sub). ---- - -# DataFrame.sub - -danfo.DataFrame.sub(other, option) \[[source](https://github.com/opensource9ja/danfojs/blob/fe56860b0a303d218d60ba71dee6abf594401556/danfojs/src/core/frame.js#L347)] - -| Parameters | Type | Description | Default | -| ---------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- | -| other | DataFrame, Series, Array or Scalar | Object to add with | | -| option | Object |

{

axis: 0 for row, 1 for column.

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

}

| { axis: 1, inplace: false } | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -### Subtraction of **scalar to** DataFrame along default axis 1 - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24] -} -let df = new dfd.DataFrame(data) - -let df_new = df.sub(2) - -df_new.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ 8 │ 21 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ 43 │ 18 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ 54 │ 8 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ 8 │ 22 ║ -╚════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Subtraction of **Series to** DataFrame along axis 0 - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Col1": [1, 4, 5, 1], - "Col2": [3, 2, 0, 4] -} - -let df = new dfd.DataFrame(data) -let sf = new dfd.Series([4, 5]) - -let df_new = df.sub(sf, { axis: 1 }) - -df_new.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ -3 │ -2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ 0 │ -3 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ 1 │ -5 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ -3 │ -1 ║ -╚════════════╧═══════════════════╧═══════════════════╝ - -``` -{% endtab %} -{% endtabs %} - -### Subtraction of **** DataFrame to a DataFrame - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs") - -let data = {"Col1": [1, 4, 5, 0], - "Col2": [2, 0, 1, 4]} - -let data2 = {"new_col1": [1, 5, 20, 10], - "new_Col2": [20, 2, 1, 2]} - -let df = new dfd.DataFrame(data) -let df2 = new dfd.DataFrame(data2) - -let df_new = df.sub(df2) - -df_new.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ 0 │ -18 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ -1 │ -2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ -15 │ 0 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ -10 │ 2 ║ -╚════════════╧═══════════════════╧═══════════════════╝ - -``` -{% endtab %} -{% endtabs %} - -### Subtraction of **** Array to DataFrame along axis 0 - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24] -} - -let df = new dfd.DataFrame(data) -let val = [2, 2, 2, 2] - -let df_new = df.sub(val, { axis: 0 }) - -df_new.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ 8 │ 21 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ 43 │ 18 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ 54 │ 8 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ 8 │ 22 ║ -╚════════════╧═══════════════════╧═══════════════════╝ - - -``` -{% endtab %} -{% endtabs %} - -### Subtraction works inplace - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "Col1": [10, 45, 56, 10], - "Col2": [23, 20, 10, 24] -} - -let df = new dfd.DataFrame(data) -let val = [2, 2, 2, 2] - -df.sub(val, { axis: 0, inplace: true }) - -df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ Col1 │ Col2 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ 8 │ 21 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ 43 │ 18 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ 54 │ 8 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ 8 │ 22 ║ -╚════════════╧═══════════════════╧═══════════════════╝ - - -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.sum.md b/api-reference-v1-stable/dataframe/danfo.dataframe.sum.md deleted file mode 100644 index 3937d3f..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.sum.md +++ /dev/null @@ -1,121 +0,0 @@ ---- -description: Return the sum of the values for the requested axis. ---- - -# DataFrame.sum - -danfo.DataFrame.**sum**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L454)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ----------------------------------------------------------------------------------- | ----------- | -| options | Object | **axis:** 0 or 1. If 0, compute the mean column-wise, if 1, row-wise. Defaults to 1 | { axis: 1 } | - -**Returns:** - - **** return **Series** - -## **Examples** - -## Sum elements along default axis (column) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") -let data = {"A": [-20.1, 30, 47.3, -20], - "B": [34, -4, 5, 6], - "C": [20, -20, 30, -40]} -let df = new dfd.DataFrame(data) - -df.print() - -let df_sum = df.sum() -df_sum.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ -20.1 │ 34 │ 20 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 30 │ -4 │ -20 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 47.3 │ 5 │ 30 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ -20 │ 6 │ -40 ║ -╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - -╔═══╤════════════════════╗ -║ A │ 37.199999999999996 ║ -╟───┼────────────────────╢ -║ B │ 41 ║ -╟───┼────────────────────╢ -║ C │ -10 ║ -╚═══╧════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -## Sum elements along row axis (0) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") -let data = {"A": [-20.1, 30, 47.3, -20], - "B": [34, -4, 5, 6], - "C": [20, -20, 30, -40]} -let df = new dfd.DataFrame(data) - -df.print() - -let df_sum = df.sum({axis: 0}) -df_sum.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ -20.1 │ 34 │ 20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 30 │ -4 │ -20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 47.3 │ 5 │ 30 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ -20 │ 6 │ -40 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - -╔═══╤══════════════════════╗ -║ │ sum ║ -╟───┼──────────────────────╢ -║ 0 │ 33.9 ║ -╟───┼──────────────────────╢ -║ 1 │ 6 ║ -╟───┼──────────────────────╢ -║ 2 │ 82.3 ║ -╟───┼──────────────────────╢ -║ 3 │ -54 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.tail.md b/api-reference-v1-stable/dataframe/danfo.dataframe.tail.md deleted file mode 100644 index 165acac..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.tail.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -description: Returns the last n rows from the DataFrame based on position. ---- - -# DataFrame.tail - -danfo.DataFrame.**tail**(rows) \[[source](https://github.com/opensource9ja/danfojs/blob/fe56860b0a303d218d60ba71dee6abf594401556/danfojs/src/core/frame.js#L292)] - -| Parameters | Type | Description | Default | -| ---------- | ---- | ---------------------------- | ------- | -| rows | Int | The number of rows to return | 5 | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "Name": ["Apples", "Mango", "Banana", "Pear"], - "Count": [21, 5, 30, 10], - "Price": [200, 300, 40, 250] } - -let df = new dfd.DataFrame(data) -let s_df = df.tail(3) -s_df.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Name │ Count │ Price ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ Banana │ 30 │ 40 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ Pear │ 10 │ 250 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/danfo.dataframe.var.md b/api-reference-v1-stable/dataframe/danfo.dataframe.var.md deleted file mode 100644 index ea0daf2..0000000 --- a/api-reference-v1-stable/dataframe/danfo.dataframe.var.md +++ /dev/null @@ -1,94 +0,0 @@ ---- -description: Return unbiased variance over requested axis. ---- - -# DataFrame.var - -danfo.DataFrame.**var**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L454)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ----------------------------------------------------------------------------------- | ----------- | -| options | Object | **axis:** 0 or 1. If 0, compute the mean column-wise, if 1, row-wise. Defaults to 1 | { axis: 1 } | - -**Returns:** - - **** return **Series** - -## **Examples** - -## Calculate variance of values along default axis 1 (column) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") -data = [[11, 20, 3], [1, 15, 6], [2, 30, 40], [2, 89, 78]] -cols = ["A", "B", "C"] - -let df = new dfd.DataFrame(data) -df.var().print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 22 ║ -╟───┼──────────────────────╢ -║ 1 │ 1172.3333333333333 ║ -╟───┼──────────────────────╢ -║ 2 │ 1232.25 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -## Calculate variance of values along row axis (0) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") -data = [[11, 20, 3], [1, 15, 6], [2, 30, 40], [2, 89, 78]] -cols = ["A", "B", "C"] - -let df = new dfd.DataFrame(data) -df.var({axis:0}).print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 72.33333333333334 ║ -╟───┼──────────────────────╢ -║ 1 │ 50.33333333333333 ║ -╟───┼──────────────────────╢ -║ 2 │ 388 ║ -╟───┼──────────────────────╢ -║ 3 │ 2244.333333333333 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - - - diff --git a/api-reference-v1-stable/dataframe/dataframe.append.md b/api-reference-v1-stable/dataframe/dataframe.append.md deleted file mode 100644 index bc2e29d..0000000 --- a/api-reference-v1-stable/dataframe/dataframe.append.md +++ /dev/null @@ -1,76 +0,0 @@ ---- -description: Adds new row to the end of a DataFrame ---- - -# DataFrame.append - -danfo.DataFrame.**append**(val) \[[source](https://github.com/opensource9ja/danfojs/blob/2696f1d8420dd364464aae7c5c175c6cd0ef4c93/danfojs/src/core/frame.js#L2059)] - -| Parameters | Type | Description | Default | -| ---------- | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------- | -| newValues | Array, Series or DataFrame | Value to append to the DataFrame | | -| index | Array | The new index value(s) to append to the Series. Must contain the same number of values as`newValues` as they map `1 - 1`. | | -| options | Object |

Optional parameters

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

|

{

inplace : false

}

| - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -### **Appends a new row to the end of a DataFrame** - -{% tabs %} -{% tab title="Node" %} -```javascript -let data = [[0, 2, 4, "b"], - [360, 180, 360, "a"], - [2, 4, 6, "c"]] - -let df = new dfd.DataFrame(data) -df.print() - -let new_df = df.append([[20, 40, 60, "d"]], [3]) -new_df.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ 0 │ 1 │ 2 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 0 │ 2 │ 4 │ b ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 360 │ 180 │ 360 │ a ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 2 │ 4 │ 6 │ c ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (4,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ 0 │ 1 │ 2 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 0 │ 2 │ 4 │ b ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 360 │ 180 │ 360 │ a ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 2 │ 4 │ 6 │ c ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 20 │ 40 │ 60 │ d ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -**** diff --git a/api-reference-v1-stable/dataframe/dataframe.apply_map.md b/api-reference-v1-stable/dataframe/dataframe.apply_map.md deleted file mode 100644 index 3819821..0000000 --- a/api-reference-v1-stable/dataframe/dataframe.apply_map.md +++ /dev/null @@ -1,68 +0,0 @@ ---- -description: Apply a function to a Dataframe values element-wise. ---- - -# DataFrame.apply\_map - -danfo.DataFrame.**apply\_map**(callable, options) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L1566)] - -| Parameters | Type | Description | Default | -| ---------- | -------- | --------------------------------------------------------------------- | --------- | -| callable | Function | Function to apply to each column or row | | -| options | Object | **axis**: 0 or 1. If 0, compute the power column-wise, if 1, row-wise | {axis: 1} | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -### Apply a function to all values in a DataFrame - -{% hint style="info" %} -Note that the specified function passed to `apply` will be called with each element in the DataFrame. If you need to apply a function across an axis, then use the [apply](danfo.dataframe.apply.md) function. -{% endhint %} - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - short_name: ["NG", "GH", "EGY", "SA"], - long_name: ["Nigeria", "Ghana", "Eqypt", "South Africa"] -} -let df = new dfd.DataFrame(data) - -function lower(x) { - return `${x}`.toLowerCase() -} - -let df_new = df.apply_map(lower) -df_new.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ short_name │ long_name ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 0 │ ng │ nigeria ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 1 │ gh │ ghana ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 2 │ egy │ eqypt ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 3 │ sa │ south africa ║ -╚════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/dataframe.astype.md b/api-reference-v1-stable/dataframe/dataframe.astype.md deleted file mode 100644 index e6434dc..0000000 --- a/api-reference-v1-stable/dataframe/dataframe.astype.md +++ /dev/null @@ -1,222 +0,0 @@ ---- -description: Cast column of a DataFrame to a specified dtype. ---- - -# DataFrame.astype - -danfo.DataFrame.**astype**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/cf5c7ae3a009458e61eedd18d9c9b5b6b10d5276/danfojs/src/core/frame.js#L125)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | -| options | Object |

{

column: Array, label/column name of column to cast

dtype: dtype to cast to. One of [string, float32, int32, boolean]

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

}

| { inplace: false } | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -### **Cast a float dtype column to int** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "A": [-20.1, 30, 47.3, -20] , - "B": [34, -4, 5, 6], - "C": [20.1, -20.23, 30.3, 40.11], - "D": ["a", "b", "c", "c"] } - -let df = new dfd.DataFrame(data) -df.print() -df.ctypes.print() - -let df_new = df.astype({column: "A", dtype: "int32"}) -df_new.print() - -df.ctypes.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -//before casting -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C │ D ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ -20.1 │ 34 │ 20.1 │ a ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 30 │ -4 │ -20.23 │ b ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 47.3 │ 5 │ 30.3 │ c ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ -20 │ 6 │ 40.11 │ c ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ A │ float32 ║ -╟───┼──────────────────────╢ -║ B │ int32 ║ -╟───┼──────────────────────╢ -║ C │ float32 ║ -╟───┼──────────────────────╢ -║ D │ string ║ -╚═══╧══════════════════════╝ - - - //after casting - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C │ D ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ -20 │ 34 │ 20.1 │ a ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 30 │ -4 │ -20.23 │ b ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 47 │ 5 │ 30.3 │ c ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ -20 │ 6 │ 40.11 │ c ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ A │ int32 ║ -╟───┼──────────────────────╢ -║ B │ int32 ║ -╟───┼──────────────────────╢ -║ C │ float32 ║ -╟───┼──────────────────────╢ -║ D │ string ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### **Casting a string column of numbers to int** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "A": [-20.1, 30, 47.3, -20] , - "B": [34, -4, 5, 6], - "C": [20.1, -20.23, 30.3, 40.11], - "D": ["20", "13", "45", "90"] } - -let df = new dfd.DataFrame(data) -let df_new = df.astype({column: "D", dtype: "int32"}) -df_new.print() - -df_new.ctypes.print() - - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C │ D ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ -20.1 │ 34 │ 20.1 │ 20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 30 │ -4 │ -20.23 │ 13 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 47.3 │ 5 │ 30.3 │ 45 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ -20 │ 6 │ 40.11 │ 90 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ A │ float32 ║ -╟───┼──────────────────────╢ -║ B │ int32 ║ -╟───┼──────────────────────╢ -║ C │ float32 ║ -╟───┼──────────────────────╢ -║ D │ int32 ║ -╚═══╧══════════════════════╝ - -``` -{% endtab %} -{% endtabs %} - -**Note:** Casting a string column of alphabets/words to numeric form will return NaNs as values - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "A": [-20.1, 30, 47.3, -20] , - "B": [34, -4, 5, 6], - "C": [20.1, -20.23, 30.3, 40.11], - "D": ["a", "b", "c", "c"] } - -let df = new dfd.DataFrame(data) -let df_new = df.astype({column: "D", dtype: "int32"}) -df_new.print() - -df_new.ctypes.print() - - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C │ D ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ -20.1 │ 34 │ 20.1 │ NaN ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 30 │ -4 │ -20.23 │ NaN ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 47.3 │ 5 │ 30.3 │ NaN ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ -20 │ 6 │ 40.11 │ NaN ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ A │ float32 ║ -╟───┼──────────────────────╢ -║ B │ int32 ║ -╟───┼──────────────────────╢ -║ C │ float32 ║ -╟───┼──────────────────────╢ -║ D │ int32 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/dataframe.axes.md b/api-reference-v1-stable/dataframe/dataframe.axes.md deleted file mode 100644 index 399a0a4..0000000 --- a/api-reference-v1-stable/dataframe/dataframe.axes.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -description: >- - Return an Object containing the axes of the DataFrame. It has the row axis - labels and column axis labels as the only members. They are returned in that - order. ---- - -# DataFrame.axis - -danfo.DataFrame.**axis** \[[source](https://github.com/opensource9ja/danfojs/blob/eb5919d2cac34271fc3b725fa24aa3ad4eacde37/danfojs/src/core/generic.js#L290)] - -**Returns:** - - **** return **Object** - -## **Examples** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"A": [-20.1, 30, 47.3, -20], - "B": [34, -4, 5, 6], - "C": [20, -20, 30, -40]} - -let df = new dfd.DataFrame(data, {index: ["a", "b", "c", "d"]}) - -console.log(df.axis) - - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -{ index: [ 'a', 'b', 'c', 'd' ], columns: [ 'A', 'B', 'C' ] } -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/dataframe.drop.md b/api-reference-v1-stable/dataframe/dataframe.drop.md deleted file mode 100644 index 0b742aa..0000000 --- a/api-reference-v1-stable/dataframe/dataframe.drop.md +++ /dev/null @@ -1,143 +0,0 @@ ---- -description: >- - Drop specified labels from rows or columns.Remove rows or columns by - specifying label names and corresponding axis. ---- - -# DataFrame.drop - -danfo.DataFrame.**drop**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/cf5c7ae3a009458e61eedd18d9c9b5b6b10d5276/danfojs/src/core/frame.js#L125)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------- | -| options | Object |

{

columns: Array of column names to drop.

index: Array of index labels to drop.

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

}

| {**inplace:**false} | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -### Drop columns by specifying the names - -By setting **inplace** to _true_, the original DataFrame is modified and nothing is returned. To not modify the original DataFrame and return a new one, set **inplace** to false or leave it as default. - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "A": [-20, 30, 47.3, -20], - "B": [34, -4, 5, 6] , - "C": [20, 20, 30, 30], - "D": ["a", "b", "c", "c"] } - -let df = new dfd.DataFrame(data) -df.drop({ columns: ["C", "B"], inplace: true }); -df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╗ -║ │ A │ D ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ -20 │ a ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ 30 │ b ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ 47.3 │ c ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ -20 │ c ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Drop rows by specifying int labels/index - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "A": [-20, 30, 47.3, -20], - "B": [34, -4, 5, 6], - "C": [20, 20, 30, 30], - "D": ["a", "b", "c", "c"] -} - -let df = new dfd.DataFrame(data) -df.drop({ index: [0, 2], inplace: true }); -df.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C │ D ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 30 │ -4 │ 20 │ b ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ -20 │ 6 │ 30 │ c ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Drop rows by specifying string labels/index - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "A": [-20, 30, 47.3, -20], - "B": [34, -4, 5, 6] , - "C": [20, 20, 30, 30], - "D": ["a", "b", "c", "c"] } - -let df = new dfd.DataFrame(data, {index: ["a", "b", "c", "d"]}) -df.drop({ index: ["a", "c"], inplace: true }); -df.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C │ D ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ b │ 30 │ -4 │ 20 │ b ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ d │ -20 │ 6 │ 30 │ c ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/dataframe.dtypes.md b/api-reference-v1-stable/dataframe/dataframe.dtypes.md deleted file mode 100644 index 791d296..0000000 --- a/api-reference-v1-stable/dataframe/dataframe.dtypes.md +++ /dev/null @@ -1,100 +0,0 @@ ---- -description: >- - Return the inferred column types in the DataFrame. This returns a Series with - the data type of each column. The result’s index is the original DataFrame’s - columns. ---- - -# DataFrame.ctypes - -danfo.DataFrame.**dtypes** \[[source](https://github.com/opensource9ja/danfojs/blob/eb5919d2cac34271fc3b725fa24aa3ad4eacde37/danfojs/src/core/frame.js#L1848)] - -**Returns:** - - **** return **Series** - -## **Examples** - -Returns auto-generated **** index of a **** DataFrame - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"A": [-20.1, 30, 47.3, -20], - "B": [34, -4, 5, 6], - "C": [20, -20, 30, -40]} - -let df = new dfd.DataFrame(data) - -df.ctypes.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ A │ float32 ║ -╟───┼──────────────────────╢ -║ B │ int32 ║ -╟───┼──────────────────────╢ -║ C │ int32 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -Columns with mixed types are represented as **string.** - -{% tabs %} -{% tab title="Node" %} -```javascript - -const dfd = require("danfojs-node") - -let data = {"A": [-20.1, 30, 47.3, -20], - "B": [34, -4, 5, 6], - "C": [20, -20, 30, -40], - "D": ["a", "b", 20, 2.5]} - -let df = new dfd.DataFrame(data) - -df.ctypes.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ A │ float32 ║ -╟───┼──────────────────────╢ -║ B │ int32 ║ -╟───┼──────────────────────╢ -║ C │ int32 ║ -╟───┼──────────────────────╢ -║ D │ string ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -**Note**: To cast a type, use the [astype](dataframe.astype.md) method. diff --git a/api-reference-v1-stable/dataframe/dataframe.index.md b/api-reference-v1-stable/dataframe/dataframe.index.md deleted file mode 100644 index a185e63..0000000 --- a/api-reference-v1-stable/dataframe/dataframe.index.md +++ /dev/null @@ -1,69 +0,0 @@ ---- -description: The index (row labels) of the DataFrame. ---- - -# DataFrame.index - -danfo.DataFrame.**index** \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/frame.js#L940)] - -## **Examples** - -Returns auto-generated **** index of a **** DataFrame - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"A": [-20.1, 30, 47.3, -20], - "B": [34, -4, 5, 6], - "C": [20, -20, 30, -40]} -let df = new dfd.DataFrame(data) - -console.log(df.index); -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -[0, 1, 2, 3] -``` -{% endtab %} -{% endtabs %} - - - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"A": [-20.1, 30, 47.3, -20], - "B": [34, -4, 5, 6], - "C": [20, -20, 30, -40]} -let df = new dfd.DataFrame(data, {index: ["r1", "r2", "r3", "r4"]) - -console.log(df.index); -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -[ 'r1', 'r2', 'r3', 'r4' ] -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/dataframe.ndim.md b/api-reference-v1-stable/dataframe/dataframe.ndim.md deleted file mode 100644 index c64dd09..0000000 --- a/api-reference-v1-stable/dataframe/dataframe.ndim.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -description: >- - Return an int representing the number of axes / array dimensions. Returns 1 if - Series. Otherwise return 2 for DataFrame. ---- - -# DataFrame.ndim - -danfo.DataFrame.**ndim** \[[source](https://github.com/opensource9ja/danfojs/blob/eb5919d2cac34271fc3b725fa24aa3ad4eacde37/danfojs/src/core/generic.js#L290)] - -**Returns:** - - **** return **Int** - -**Note:** To get the **shape** of the DataFrame use the .[shape](dataframe.shape.md) property. - -## **Examples** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"A": [-20.1, 30, 47.3, -20], - "B": [34, -4, 5, 6], - "C": [20, -20, 30, -40]} -let df = new dfd.DataFrame(data) - -console.log(df.ndim) - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -2 -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/dataframe.nunique-1.md b/api-reference-v1-stable/dataframe/dataframe.nunique-1.md deleted file mode 100644 index 8166904..0000000 --- a/api-reference-v1-stable/dataframe/dataframe.nunique-1.md +++ /dev/null @@ -1,98 +0,0 @@ -# DataFrame.nunique - -danfo.DataFrame.**nunique**(axis) \[[source](https://github.com/opensource9ja/danfojs/blob/f84d7f53f2b0639e464f9483fb5cea969ad913d6/danfojs/src/core/frame.js#L1975)] - -| Parameters | Type | Description | Default | -| ---------- | ---- | -------------------------------------- | ------- | -| axis | Int | 0 for row axis, and 1 for column axis | 1 | - -**Returns:** - - **** return **Series** - -## **Examples** - -### Return number of unique values along column axis (axis=1) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "A": [-20, 30, 47.3, -20] , - "B": [34, -4, 5, 6] , - "C": [20, 20, 30, 30], - "D": ["a", "b", "c", "c"] } - -let df = new dfd.DataFrame(data) -df.nunique().print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══╗ -║ 0 │ 3 ║ -╟───┼───╢ -║ 1 │ 4 ║ -╟───┼───╢ -║ 2 │ 2 ║ -╟───┼───╢ -║ 3 │ 3 ║ -╚═══╧═══╝ - -``` -{% endtab %} -{% endtabs %} - -### Return number of unique values in row axis (axis=0) - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "A": [-20, 30, 47.3, -20] , - "B": [34, -4, 5, 6] , - "C": [20, 20, 30, 30], - "D": ["a", "b", "c", "c"] } - -let df = new dfd.DataFrame(data) -df.nunique(axis=0).print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 4 ║ -╟───┼──────────────────────╢ -║ 1 │ 4 ║ -╟───┼──────────────────────╢ -║ 2 │ 4 ║ -╟───┼──────────────────────╢ -║ 3 │ 4 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -**Note:** To get the unique elements along an axis, use **** [DataFrame.unique.](dataframe.nunique-1.md) diff --git a/api-reference-v1-stable/dataframe/dataframe.print.md b/api-reference-v1-stable/dataframe/dataframe.print.md deleted file mode 100644 index d03232d..0000000 --- a/api-reference-v1-stable/dataframe/dataframe.print.md +++ /dev/null @@ -1,105 +0,0 @@ ---- -description: >- - Pretty prints default (10) number of rows in a DataFrame or Series to the - console ---- - -# DataFrame.print - -danfo.DataFrame.**print()** \[[source](https://github.com/opensource9ja/danfojs/blob/eb5919d2cac34271fc3b725fa24aa3ad4eacde37/danfojs/src/core/generic.js#L290)] - -## **Examples** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "Abs": [20.2, 30, 47.3] , - "Count": [34, 4, 5] , - "country code": ["NG", "FR", "GH"] } - - -let df = new dfd.DataFrame(data) -df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Abs │ Count │ country code ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 20.2 │ 34 │ NG ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 30 │ 4 │ FR ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 47.3 │ 5 │ GH ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -Using JavaScript default **console.log** to display a DataFrame will return the Object instead unless you manually cast it to a String - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "Abs": [20.2, 30, 47.3] , - "Count": [34, 4, 5, 6] , - "country code": ["NG", "FR", "GH"] } - - -let df = new dfd.DataFrame(data) -console.log(df) -console.log(String(df)); -// console.log(df + ""); //same result as above -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -DataFrame { - '$isSeries': false, - '$config': Configs { - tableDisplayConfig: {}, - tableMaxRow: 10, - tableMaxColInConsole: 21, - dtypeTestLim: 7, - lowMemoryMode: false - }, - '$data': [ [ 20.2, 34, 'NG' ], [ 30, 5, 'FR' ], [ 47.3, 6, 'GH' ] ], - '$dataIncolumnFormat': [ [ 20.2, 30, 47.3 ], [ 34, 5, 6 ], [ 'NG', 'FR', 'GH' ] ], - '$index': [ 0, 1, 2 ], - '$dtypes': [ 'float32', 'int32', 'string' ], - '$columns': [ 'Abs', 'Count', 'country code' ] -} -╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Abs │ Count │ country code ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 20.2 │ 34 │ NG ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 30 │ 5 │ FR ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 47.3 │ 6 │ GH ║ -╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/dataframe.rename.md b/api-reference-v1-stable/dataframe/dataframe.rename.md deleted file mode 100644 index c33ce99..0000000 --- a/api-reference-v1-stable/dataframe/dataframe.rename.md +++ /dev/null @@ -1,148 +0,0 @@ ---- -description: >- - Change axes labels. Object values must be unique (1-to-1). Labels not - contained in a dict / Series will be left as-is. Extra labels listed don’t - throw an error. ---- - -# DataFrame.rename - -danfo.DataFrame.**rename**(kwargs) \[[source](https://github.com/opensource9ja/danfojs/blob/cf5c7ae3a009458e61eedd18d9c9b5b6b10d5276/danfojs/src/core/frame.js#L125)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------------- | -| options | Object |

{

mapper: Object of labels and transformations to apply to that axis’ values.

axis: row=0, columns=1.

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

}

| {**axis**: 1, **inplace:**false} | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -### Rename columns - -By setting **inplace** to _true_, the original DataFrame is modified and nothing is returned. To not modify the original DataFrame and return a new one, set **inplace** to false or leave it as default. - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "A": [-20, 30, 47.3], - "B": [34, -4, 5], - "C": [20, 2, 30] } - - -let df = new dfd.DataFrame(data) -df.rename({ mapper: {"A": "new_name"},inplace: true }) -df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ new_name │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ -20 │ 34 │ 20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 30 │ -4 │ 20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 47.3 │ 5 │ 30 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Rename more the one column at time - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "A": [-20, 30, 47.3], - "B": [34, -4, 6], - "C": [20, 2, 30] } - - -let df = new dfd.DataFrame(data) -df = df.rename({ mapper: {"A": "new_name", "C": "new_c"}}) -df.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ new_name │ B │ new_c ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ -20 │ 34 │ 20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 30 │ -4 │ 20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 47.3 │ 5 │ 30 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Rename index by labels - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - "A": [-20, 30, 47.3], - "B": [34, -4, 6], - "C": [20, 2, 30] -} - - -let df = new dfd.DataFrame(data, { index: ["a", "b", "c"] }) -df = df.rename({ mapper: { "a": 0 }, axis: 0 }) -df.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ -20 │ 34 │ 20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ b │ 30 │ -4 │ 20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 47.3 │ 5 │ 30 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/dataframe.select_dtypes.md b/api-reference-v1-stable/dataframe/dataframe.select_dtypes.md deleted file mode 100644 index ba5044e..0000000 --- a/api-reference-v1-stable/dataframe/dataframe.select_dtypes.md +++ /dev/null @@ -1,94 +0,0 @@ ---- -description: Return a subset of the DataFrame’s columns based on the column dtypes. ---- - -# DataFrame.select\_dtypes - -danfo.DataFrame.**select\_dtypes** \[[source](https://github.com/opensource9ja/danfojs/blob/db48bf9701e1c3205811ba2699b42ce56ef7e63b/danfojs/src/core/frame.js#L778)] - -| Parameters | Type | Description | Default | -| ---------- | ----- | -------------------------------- | ------- | -| include | Array | List of column dtypes to return | | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"A": [-20.1, 30, 47.3, -20], - "B": [34, -4, 5, 6], - "C": [20, -20, 30, -40], - "D": ["a", "b", 20, 2.5]} - -let df = new dfd.DataFrame(data) - -float_df = df.select_dtypes(['float32']) -float_df.print() - -mix_df = df.select_dtypes(include=['float32', "int32"]) -mix_df.print() - -str_df = df.select_dtypes(include=['string']) -str_df.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -//select float column(s) -╔═══╤══════════════════════╗ -║ │ A ║ -╟───┼──────────────────────╢ -║ 0 │ -20.1 ║ -╟───┼──────────────────────╢ -║ 1 │ 30 ║ -╟───┼──────────────────────╢ -║ 2 │ 47.3 ║ -╟───┼──────────────────────╢ -║ 3 │ -20 ║ -╚═══╧══════════════════════╝ - - - //select both float and int columns - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ -20.1 │ 34 │ 20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 30 │ -4 │ -20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 47.3 │ 5 │ 30 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ -20 │ 6 │ -40 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - -//return string type column -╔═══╤══════════════════════╗ -║ │ D ║ -╟───┼──────────────────────╢ -║ 0 │ a ║ -╟───┼──────────────────────╢ -║ 1 │ b ║ -╟───┼──────────────────────╢ -║ 2 │ 20 ║ -╟───┼──────────────────────╢ -║ 3 │ 2.5 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/dataframe.set_index.md b/api-reference-v1-stable/dataframe/dataframe.set_index.md deleted file mode 100644 index e82c213..0000000 --- a/api-reference-v1-stable/dataframe/dataframe.set_index.md +++ /dev/null @@ -1,176 +0,0 @@ ---- -description: >- - Set the DataFrame index using existing columns or an array (of the equal - length). ---- - -# DataFrame.set_index - -danfo.DataFrame.**set_index**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/cf5c7ae3a009458e61eedd18d9c9b5b6b10d5276/danfojs/src/core/frame.js#L125)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------ | -| options | Object |

{

index: An array of index values to set.

column: A column name to set the index to.

drop: Whether to drop the column whose index was set. Defaults to false.

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

}

| {**drop**: false, **inplace:**false} | - -## **Examples** - -### **Setting index to a column in the DataFrame** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "A": [-20, 30, 47.3], - "B": [34, 5, 6], - "C": [20, 3, 30] } - - -let df = new dfd.DataFrame(data, {index: ["a", "b", "c"]}) -df.print() - -df.set_index({column: "A", inplace: true}) -df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ a │ -20 │ 34 │ 20 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ b │ 30 │ 5 │ 3 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ c │ 47.3 │ 6 │ 30 ║ -╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - -╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ -20 │ -20 │ 34 │ 20 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 30 │ 30 │ 5 │ 3 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 47.3 │ 47.3 │ 6 │ 30 ║ -╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### **** - -### **Setting index to a column in the DataFrame and dropping the column** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "A": [-20, 30, 47.3], - "B": [34, 5, 6], - "C": [20, 3, 30] } - - -let df = new dfd.DataFrame(data, {index: ["a", "b", "c"]}) -df.print() - -df.set_index({column: "A", drop: true, inplace: true}) -df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ a │ -20 │ 34 │ 20 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ b │ 30 │ 5 │ 3 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ c │ 47.3 │ 6 │ 30 ║ -╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - -╔════════════╤═══════════════════╤═══════════════════╗ -║ │ B │ C ║ -╟────────────┼───────────────────┼───────────────────╢ -║ -20 │ 34 │ 20 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 30 │ 5 │ 3 ║ -╟────────────┼───────────────────┼───────────────────╢ -║ 47.3 │ 6 │ 30 ║ -╚════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### **Set index to an array of the same length** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "A": [-20, 30, 47.3], - "B": [34, -5, 6], - "C": [20, 3, 30] } - - -let df = new dfd.DataFrame(data) -df.print() - -let new_index = ["a", "b", "c"] -df.set_index({index: new_index, inplace: true}) -df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ -20 │ 34 │ 20 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 30 │ -5 │ 3 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 47.3 │ 6 │ 30 ║ -╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - -╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ a │ -20 │ 34 │ 20 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ b │ 30 │ -5 │ 3 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ c │ 47.3 │ 6 │ 30 ║ -╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -**Note:** To reset an index to the default values, use the [DataFrame.reset_index](dataframe.reset_index.md). diff --git a/api-reference-v1-stable/dataframe/dataframe.shape.md b/api-reference-v1-stable/dataframe/dataframe.shape.md deleted file mode 100644 index 746491d..0000000 --- a/api-reference-v1-stable/dataframe/dataframe.shape.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -description: Returns an Array representing the dimensionality of the DataFrame. ---- - -# DataFrame.shape - -danfo.DataFrame.**shape** \[[source](https://github.com/opensource9ja/danfojs/blob/eb5919d2cac34271fc3b725fa24aa3ad4eacde37/danfojs/src/core/generic.js#L290)] - -**Returns:** - - **** return **Int** - -## **Examples** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"A": [-20.1, 30, 47.3, -20], - "B": [34, -4, 5, 6], - "C": [20, -20, 30, -40]} -let df = new dfd.DataFrame(data, {index: ["a", "b", "c", "d"]}) - -console.log(df.shape) - - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -[4,3] -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/dataframe.sort_index.md b/api-reference-v1-stable/dataframe/dataframe.sort_index.md deleted file mode 100644 index 81d5b7f..0000000 --- a/api-reference-v1-stable/dataframe/dataframe.sort_index.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -description: Sort DataFrame by index ---- - -# DataFrame.sort\_index - -DataFrame.**sort\_index**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/e25010c26d9c423412613d820015a48ad03d5c6d/danfojs-node/src/core/frame.js#L2094)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------- | -| options | Object |

{

ascending: Sorting order.

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

}

| {**ascending**: true, **inplace:**false} | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -### **Sort DataFrame by a column in ascending order** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = [[0, 2, 4, "b"], - [360, 180, 360, "a"], - [2, 4, 6, "c"]] - -let df = new dfd.DataFrame(data, { "columns": ["col1", "col2", "col3", "col4"], - index: ["b", "a", "c"] }) -df.print() - -let df2 = df.sort_index({ ascending: false }) -df2.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ col1 │ col2 │ col3 │ col4 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ b │ 0 │ 2 │ 4 │ b ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ a │ 360 │ 180 │ 360 │ a ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ c │ 2 │ 4 │ 6 │ c ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - //after sorting in descending order - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ col1 │ col2 │ col3 │ col4 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ c │ 2 │ 4 │ 6 │ c ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ b │ 0 │ 2 │ 4 │ b ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ a │ 360 │ 180 │ 360 │ a ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -**** diff --git a/api-reference-v1-stable/dataframe/dataframe.sort_values.md b/api-reference-v1-stable/dataframe/dataframe.sort_values.md deleted file mode 100644 index 54345b1..0000000 --- a/api-reference-v1-stable/dataframe/dataframe.sort_values.md +++ /dev/null @@ -1,99 +0,0 @@ ---- -description: Sort a Dataframe in ascending or descending order by a specified column name. ---- - -# DataFrame.sort\_values - -danfo.DataFrame.**sort\_values**(kwargs) \[[source](https://github.com/opensource9ja/danfojs/blob/cf5c7ae3a009458e61eedd18d9c9b5b6b10d5276/danfojs/src/core/frame.js#L125)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------- | -| options | Object |

{

by: This key can be either a single column name or a single array of the same length as the calling DataFrame,

ascending: Order of sorting

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

}

| {**ascending**: true, **inplace:**false} | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -### **Sort DataFrame by a column in ascending order** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "A": [-20, 30, 47.3], - "B": [34, 5, 6], - "C": [20, 3, 30] } - - -let df = new dfd.DataFrame(data) -df.sort_values({by: "C", inplace: true}) -df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` - -╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 30 │ 5 │ 3 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ -20 │ 34 │ 20 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 47.3 │ 6 │ 30 ║ -╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### **Sort DataFrame by a column in descending order** - -{% tabs %} -{% tab title="Node" %} -```javascript - -const dfd = require("danfojs-node") - -let data = { "A": [-20, 30, 47.3], - "B": [34, 5, 6], - "C": [20, 3, 30] } - - -let df = new dfd.DataFrame(data) -df.sort_values({by: "B", inplace: true, ascending: false}) -df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ -20 │ 34 │ 20 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 47.3 │ 6 │ 30 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 30 │ 5 │ 3 ║ -╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/dataframe.tensor.md b/api-reference-v1-stable/dataframe/dataframe.tensor.md deleted file mode 100644 index 822886e..0000000 --- a/api-reference-v1-stable/dataframe/dataframe.tensor.md +++ /dev/null @@ -1,110 +0,0 @@ ---- -description: >- - Return a Tensorflow tensor representation of the DataFrame. Only the values in - the DataFrame will be returned, the axes labels will be removed. ---- - -# DataFrame.tensor - -danfo.DataFrame.**tensor** \[[source](https://github.com/opensource9ja/danfojs/blob/eb5919d2cac34271fc3b725fa24aa3ad4eacde37/danfojs/src/core/generic.js#L290)] - -**Returns:** - - **** return **tf.tensor** - -> **Note:** [Tensorflow](https://js.tensorflow.org/api/latest/#tensor) tensors have single dtype, and will replace any string value with NaN. Use with care. - -## **Examples** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "A": [-20, 30, 47.3, -20] , - "B": [34, -4, 5, 6] , - "C": [20, 20, 30, 30]} - -let df = new dfd.DataFrame(data) -let tf_tensor = df.tensor - -console.log(tf_tensor.dtype); - -console.log(tf_tensor); - -tf_tensor.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -float32 -Tensor - [[-20 , 34, 20], - [30 , -4, 20], - [47.2999992, 5 , 30], - [-20 , 6 , 30]] -``` -{% endtab %} -{% endtabs %} - -String values in a Tensor are represented as NaN, so ensure to transform them before working with tensor representations. - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { "Abs": [20.2, 30, 47.3] , - "Count": [34, 5, 6] , - "country code": ["NG", "FR", "GH"] } - - -let df = new dfd.DataFrame(data) -let tf_tensor = df.tensor - -console.log(tf_tensor.dtype); - -console.log(tf_tensor); - -tf_tensor.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -float32 - -Tensor { - kept: false, - isDisposedInternal: false, - shape: [ 3, 3 ], - dtype: 'float32', - size: 9, - strides: [ 3 ], - dataId: {}, - id: 0, - rankType: '2' -} - -Tensor - [[20.2000008, 34, NaN], - [30 , 4 , NaN], - [47.2999992, 5 , NaN]] -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/dataframe/dataframe.to_csv.md b/api-reference-v1-stable/dataframe/dataframe.to_csv.md deleted file mode 100644 index 8e84e9a..0000000 --- a/api-reference-v1-stable/dataframe/dataframe.to_csv.md +++ /dev/null @@ -1,114 +0,0 @@ ---- -description: Convert DataFrame data to a comma-separated values (csv) ---- - -# DataFrame.to\_csv - -DataFrame.**to\_csv**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/cf5c7ae3a009458e61eedd18d9c9b5b6b10d5276/danfojs/src/core/frame.js#L125)] - -| | | | | -| -------------- | ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | -| **Parameters** | Type | Description | Default | -| **options** | object, optional |

Configuration object:

{

filePath: Local file path to write the CSV file to. If not specified, the CSV will be returned as a string. Only needed in Nodejs version
fileName: The name of the file to download as. Only needed in browser environment.
download: Boolean indicating whether to automatically download the CSV file in the browser. Only needed in the browser environment.

header: Boolean indicating whether to include a header row in the CSV file.

sep: Character to be used as a separator in the CSV file.

}

|

{
download: true,
sep: ","

}

| - -The **to\_csv** function can be used to write out a DataFrame or Series to CSV file. The output is configurable and will depend on the environment. In the following examples, we show you how to write/download a CSV file from Node and Browser environments. - -*** - -### Convert DataFrame to CSV string and return value - -{% tabs %} -{% tab title="Node.js" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - Abs: [20.2, 30, 47.3], - Count: [34, 4, 5], - "country code": ["NG", "FR", "GH"], -}; - -let df = new dfd.DataFrame(data); - -const csv = df.to_csv({ download: false }); -console.log(csv); - -//output -Abs,Count,country code -20.2,34,NG -30,4,FR -47.3,5,GH -``` -{% endtab %} - -{% tab title="Browser" %} -```markup - - - - - - - - Document - - - - - - - - -``` -{% endtab %} -{% endtabs %} - -### Convert DataFrame to CSV string and write to file path - -Writing a CSV file to a local file path is only supported in the Nodejs environment - -{% tabs %} -{% tab title="Node.js" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - Abs: [20.2, 30, 47.3], - Count: [34, 4, 5], - "country code": ["NG", "FR", "GH"], -}; - -let df = new dfd.DataFrame(data); - -df.to_csv({ filePath: "testOut.csv"}); -``` -{% endtab %} -{% endtabs %} - -### Convert DataFrame to CSV string and download file in browser - -You can automatically convert and download a CSV file in a browser environment, by specifying a `fileName` and setting `download` to **true**. - -```javascript -let data = { - Abs: [20.2, 30, 47.3], - Count: [34, 4, 5], - "country code": ["NG", "FR", "GH"], -}; - -let df = new dfd.DataFrame(data); - -df.to_csv({ fileName: "testOut.csv", download: true}); -``` diff --git a/api-reference-v1-stable/dataframe/dataframe.to_excel.md b/api-reference-v1-stable/dataframe/dataframe.to_excel.md deleted file mode 100644 index 4adf437..0000000 --- a/api-reference-v1-stable/dataframe/dataframe.to_excel.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -description: >- - Converts a DataFrame or Series to Excel file and write file to disk or - download in browser. ---- - -# DataFrame.to_excel - -> DataFrame.**to_excel**(options) [\[source](https://github.com/opensource9ja/danfojs/blob/e25010c26d9c423412613d820015a48ad03d5c6d/danfojs-node/src/io/io.excel.js#L97)] - -| **Parameters** | Type | Description | Default | -| -------------- | ----------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -| **options** | object, optional |

Configuration object:

{

filePath: Local file path to write the CSV file to. If not specified, the CSV will be returned as a string. Only needed in Nodejs version
fileName: The name of the file to download as. Only needed in the browser environment.
sheetName: Name to call the excel sheet.

}

|

{
filePath: "./output.xlsx",
sheetName: "Sheet1"

}

| - -The **to_excel** function can be used to write out a DataFrame or Series to Excel (**.xlsx**) file. The output format will depend on the environment. In the following examples, we show you how to write/download an Excel file from Node and Browser environments. - -### Convert DataFrame to Excel and write to file path - -Writing an Excel file to a local file path is only supported in the Nodejs environment - -{% tabs %} -{% tab title="Node.js" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - Abs: [20.2, 30, 47.3], - Count: [34, 4, 5], - "country code": ["NG", "FR", "GH"], -}; - -let df = new dfd.DataFrame(data); - -df.to_excel({ filePath: "testOut.xlsx"}); -``` -{% endtab %} -{% endtabs %} - -### Convert DataFrame to Excel and download the file in a browser - -You can automatically convert and download an Excel file in a browser environment, by specifying a `fileName`. - -```javascript -let data = { - Abs: [20.2, 30, 47.3], - Count: [34, 4, 5], - "country code": ["NG", "FR", "GH"], -}; - -let df = new dfd.DataFrame(data); - -df.to_excel({ fileName: "testOut.xlsx"}); -``` diff --git a/api-reference-v1-stable/dataframe/dataframe.to_json.md b/api-reference-v1-stable/dataframe/dataframe.to_json.md deleted file mode 100644 index 326f422..0000000 --- a/api-reference-v1-stable/dataframe/dataframe.to_json.md +++ /dev/null @@ -1,127 +0,0 @@ ---- -description: Convert DataFrame to JSON format ---- - -# DataFrame.to\_json - -> DataFrame.**to\_json**(options) [\[source](https://github.com/opensource9ja/danfojs/blob/e25010c26d9c423412613d820015a48ad03d5c6d/danfojs-node/src/io/io.json.js#L92)] - -| | | | | -| -------------- | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- | -| **Parameters** | Type | Description | Default | -| **options** | object, optional |

Configuration object:

{

filePath: Local file path to write the CSV file to. If not specified, the CSV will be returned as a string. Only needed in Nodejs version
fileName: The name of the file to download as. Only needed in browser environment.
format: The format of the JSON. Can be one of row or column.

}

|

{
format: "column"
}

| - -The **to\_json** function can be used to write out a DataFrame or Series to JSON format/file. The output is configurable and will depend on the environment. In the following examples, we show you how to write/download a JSON file from Node and Browser environments. - -### Convert DataFrame/Series to JSON and return value - -{% tabs %} -{% tab title="Node.js" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - Abs: [20.2, 30, 47.3], - Count: [34, 4, 5], - "country code": ["NG", "FR", "GH"], -}; - -let df = new dfd.DataFrame(data); - -const jsonObj = df.to_json({ download: false }); //column format -console.log(jsonObj); - -//output -[ - { Abs: 20.2, Count: 34, 'country code': 'NG' }, - { Abs: 30, Count: 4, 'country code': 'FR' }, - { Abs: 47.3, Count: 5, 'country code': 'GH' } -] - -//row format -const jsonObj = df.to_json({ - download: false, - format: "row" -}); - -console.log(jsonObj); -//output -{ - Abs: [ 20.2, 30, 47.3 ], - Count: [ 34, 4, 5 ], - 'country code': [ 'NG', 'FR', 'GH' ] -} -``` -{% endtab %} - -{% tab title="Browser" %} -```markup - - - - - - - - Document - - - - - - - - -``` -{% endtab %} -{% endtabs %} - -### Convert DataFrame/Series to JSON and write to file path - -Writing a DataFrame/Series as JSON, to a local file path is only supported in the Nodejs environment - -{% tabs %} -{% tab title="Node.js" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - Abs: [20.2, 30, 47.3], - Count: [34, 4, 5], - "country code": ["NG", "FR", "GH"], -}; - -let df = new dfd.DataFrame(data); - -df.to_json({ filePath: "./testOutput.json" }); -``` -{% endtab %} -{% endtabs %} - -### Convert DataFrame/Series to JSON and download file in browser - -You can automatically convert and download a DataFrame/Series as a JSON file in a browser environment, by specifying a `fileName` and setting `download` to **true**. - -```javascript -let data = { - Abs: [20.2, 30, 47.3], - Count: [34, 4, 5], - "country code": ["NG", "FR", "GH"], -}; - -let df = new dfd.DataFrame(data); - -df.to_json({ fileName: "test_out.json" }); -``` diff --git a/api-reference-v1-stable/dataframe/dataframe.values.md b/api-reference-v1-stable/dataframe/dataframe.values.md deleted file mode 100644 index 598e395..0000000 --- a/api-reference-v1-stable/dataframe/dataframe.values.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -description: Return a the JavaScript array representation of the DataFrame. ---- - -# DataFrame.values - -danfo.DataFrame.**values** \[[source](https://github.com/opensource9ja/danfojs/blob/eb5919d2cac34271fc3b725fa24aa3ad4eacde37/danfojs/src/core/generic.js#L290)] - -**Returns:** - - **** return **Array** - -**Note:** To get the [Tensorflow](https://js.tensorflow.org) tensor backing the DataFrame, you can call the **.**[**tensor**](dataframe.tensor.md) property on the DataFrame. - -## **Examples** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = {"A": [-20.1, 30, 47.3, -20], - "B": [34, -4, 5, 6], - "C": [20, -20, 30, -40]} - -let df = new dfd.DataFrame(data) - -console.log(df.values) - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -[ - [ -20.1, 34, 20 ], - [ 30, -4, -20 ], - [ 47.3, 5, 30 ], - [ -20, 6, -40 ] -] -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/general-functions/README.md b/api-reference-v1-stable/general-functions/README.md deleted file mode 100644 index 07815b0..0000000 --- a/api-reference-v1-stable/general-functions/README.md +++ /dev/null @@ -1,27 +0,0 @@ ---- -description: Top level functions that can be called from the Danfo namespace ---- - -# General Functions - -### Data manipulations - -| | | -| ------------------------------------- | ----------------------------------------------------------------------------------------------- | -| [`merge`](danfo.merge.md) | Merge DataFrame or named Series objects with a database-style join. | -| [`concat`](danfo.concat.md) | Concatenate danfo objects along a particular axis with optional set logic along the other axes. | -| [`get_dummies`](danfo.get_dummies.md) | Convert categorical variable into dummy/indicator variables. Similar to OneHotEncoding | - -### Data Processing/Normalization - -| [LabelEncoder](danfo.labelencoder.md) | Encode target labels with value between 0 and n_classes-1. | -| ----------------------------------------- | ---------------------------------------------------------------------- | -| [OneHotEncoder](danfo.onehotencoder.md) | Encode categorical features as a one-hot numeric array. | -| [StandardScaler](danfo.standardscaler.md) | Standardize features by removing the mean and scaling to unit variance | -| [`MinMaxScaler`](danfo.minmaxscaler.md) | Transform features by scaling each feature to a given range | - -### Top-level dealing with datetime - -| [`toDateTime`](danfo.to_datetime.md) | Convert argument to datetime. | -| ------------------------------------ | --------------------------------------- | -| [`date_range`](danfo.date_range.md) | Return a fixed frequency DatetimeIndex. | diff --git a/api-reference-v1-stable/general-functions/danfo.concat.md b/api-reference-v1-stable/general-functions/danfo.concat.md deleted file mode 100644 index e248f46..0000000 --- a/api-reference-v1-stable/general-functions/danfo.concat.md +++ /dev/null @@ -1,187 +0,0 @@ ---- -description: Concatenate DataFrames and Series along an axis ---- - -# danfo.concat - -danfo.**concat**(kwargs) \[[source](https://github.com/opensource9ja/danfojs/blob/fe56860b0a303d218d60ba71dee6abf594401556/danfojs/src/core/frame.js#L254)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------- | -| **kwargs** | Object |

{

df_list: List of DataFrames or Series to concatenate together.

axis: One of 0 or 1. The axis on which to perform concatenation. Specified axis must align in both Objects

}

| {**axis**: 1} | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -### **Concatenate two DataFrames along column axis (1)** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data = [['K0', 'k0', 'A0', 'B0'], ['k0', 'K1', 'A1', 'B1'], -['K1', 'K0', 'A2', 'B2'], ['K2', 'K2', 'A3', 'B3']] - -let data2 = [['K0', 'k0', 'C0', 'D0'], ['K1', 'K0', 'C1', 'D1'], -['K1', 'K0', 'C2', 'D2'], ['K2', 'K0', 'C3', 'D3']] - -let colum1 = ['Key1', 'Key2', 'A', 'B'] -let colum2 = ['Key1', 'Key2', 'A', 'D'] - -let df1 = new dfd.DataFrame(data, { columns: colum1 }) -let df2 = new dfd.DataFrame(data2, { columns: colum2 }) - - -let com_df = dfd.concat({ df_list: [df1, df2], axis: 1 }) -com_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Key1 │ Key2 │ A │ ... │ Key1_2 │ Key2_2 │ A_2 │ D ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ K0 │ k0 │ A0 │ ... │ K0 │ k0 │ C0 │ D0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ k0 │ K1 │ A1 │ ... │ K1 │ K0 │ C1 │ D1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ K1 │ K0 │ A2 │ ... │ K1 │ K0 │ C2 │ D2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ K2 │ K2 │ A3 │ ... │ K2 │ K0 │ C3 │ D3 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### **Concatenate two DataFrames along row axis (0)** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data = [['K0', 'k0', 'A0', 'B0'], ['k0', 'K1', 'A1', 'B1'], -['K1', 'K0', 'A2', 'B2'], ['K2', 'K2', 'A3', 'B3']] - -let data2 = [['K0', 'k0', 'C0', 'D0'], ['K1', 'K0', 'C1', 'D1'], -['K1', 'K0', 'C2', 'D2'], ['K2', 'K0', 'C3', 'D3']] - -let colum1 = ['Key1', 'Key2', 'A', 'B'] -let colum2 = ['Key1', 'Key2', 'A', 'D'] - -let df1 = new dfd.DataFrame(data, { columns: colum1 }) -let df2 = new dfd.DataFrame(data2, { columns: colum2 }) - - -let com_df = dfd.concat({ df_list: [df1, df2], axis: 0 }) -com_df.print(10) -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Key1 │ Key2 │ A │ B │ D ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ K0 │ k0 │ A0 │ B0 │ NaN ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ k0 │ K1 │ A1 │ B1 │ NaN ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ K1 │ K0 │ A2 │ B2 │ NaN ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ K2 │ K2 │ A3 │ B3 │ NaN ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ K0 │ k0 │ C0 │ NaN │ D0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 5 │ K1 │ K0 │ C1 │ NaN │ D1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 6 │ K1 │ K0 │ C2 │ NaN │ D2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 7 │ K2 │ K0 │ C3 │ NaN │ D3 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### **Concatenate two Series along row axis (0)** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data = [['K0', 'k0', 'A0', 'B0'], ['k0', 'K1', 'A1', 'B1'], -['K1', 'K0', 'A2', 'B2'], ['K2', 'K2', 'A3', 'B3']] - -let data2 = [['K0', 'k0', 'C0', 'D0'], ['K1', 'K0', 'C1', 'D1'], -['K1', 'K0', 'C2', 'D2'], ['K2', 'K0', 'C3', 'D3']] - -let colum1 = ['Key1', 'Key2', 'A', 'B'] -let colum2 = ['Key1', 'Key2', 'A', 'D'] - -let df1 = new dfd.DataFrame(data, { columns: colum1 }) -let df2 = new dfd.DataFrame(data2, { columns: colum2 }) - - -let com_df = dfd.concat({ df_list: [df1, df2], axis: 0 }) -com_df.print(10) -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Key1 │ Key2 │ A │ B │ D ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ K0 │ k0 │ A0 │ B0 │ NaN ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ k0 │ K1 │ A1 │ B1 │ NaN ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ K1 │ K0 │ A2 │ B2 │ NaN ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ K2 │ K2 │ A3 │ B3 │ NaN ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ K0 │ k0 │ C0 │ NaN │ D0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 5 │ K1 │ K0 │ C1 │ NaN │ D1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 6 │ K1 │ K0 │ C2 │ NaN │ D2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 7 │ K2 │ K0 │ C3 │ NaN │ D3 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -See also [danfo.concat ](danfo.concat.md)for joining objects based on axis. diff --git a/api-reference-v1-stable/general-functions/danfo.date_range.md b/api-reference-v1-stable/general-functions/danfo.date_range.md deleted file mode 100644 index 9c4a337..0000000 --- a/api-reference-v1-stable/general-functions/danfo.date_range.md +++ /dev/null @@ -1,111 +0,0 @@ ---- -description: Return a fixed frequency Dates spread between start and end parameters. ---- - -# danfo.date\_range - -danfo.**date\_range**(kwargs) \[[source](https://github.com/opensource9ja/danfojs/blob/fe56860b0a303d218d60ba71dee6abf594401556/danfojs/src/core/frame.js#L254)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------- | -| **kwargs** | Object |

{

start: str or datetime-like. Left bound for generating dates.

end: str or datetime-like. Right bound for generating dates.

period : int. Number of periods to generate.

freq: str or DateOffset, one of ["M","D","s","H","m","Y"].

}

| {**freq:** 'D'} | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = new dfd.date_range({"start":'1/1/2018',period:5, freq:'M'}) -console.log(data); -``` -{% endtab %} - -{% tab title="Browser" %} -```markup - - - - - - - - - Document - - - - - - - - - -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -[ - '1/1/2018, 12:00:00 AM', - '2/1/2018, 12:00:00 AM', - '3/1/2018, 12:00:00 AM', - '4/1/2018, 12:00:00 AM', - '5/1/2018, 12:00:00 AM' -] -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = new dfd.date_range({"start":'1/1/2018',period:12, freq:'Y'}) -console.log(data); -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -[ - '1/1/2018, 12:00:00 AM', - '1/1/2019, 12:00:00 AM', - '1/1/2020, 12:00:00 AM', - '1/1/2021, 12:00:00 AM', - '1/1/2022, 12:00:00 AM', - '1/1/2023, 12:00:00 AM', - '1/1/2024, 12:00:00 AM', - '1/1/2025, 12:00:00 AM', - '1/1/2026, 12:00:00 AM', - '1/1/2027, 12:00:00 AM', - '1/1/2028, 12:00:00 AM', - '1/1/2029, 12:00:00 AM' -] -``` -{% endtab %} -{% endtabs %} - -{% hint style="info" %} -datetime properties of Series or datetime-like columns in DataFrame can be accessed via accessors in the **dt** name space. See [Accessors](https://app.gitbook.com/@jsdata/s/danfojs/\~/drafts/-MEMaWwva1cjt8CxnG-b/api-reference/series#accessors) -{% endhint %} diff --git a/api-reference-v1-stable/general-functions/danfo.get_dummies.md b/api-reference-v1-stable/general-functions/danfo.get_dummies.md deleted file mode 100644 index e53fd81..0000000 --- a/api-reference-v1-stable/general-functions/danfo.get_dummies.md +++ /dev/null @@ -1,188 +0,0 @@ ---- -description: Convert categorical variable into dummy/indicator variables. ---- - -# danfo.get\_dummies - -danfo.**get\_dummies**(kwargs) \[[source](https://github.com/opensource9ja/danfojs/blob/fe56860b0a303d218d60ba71dee6abf594401556/danfojs/src/core/frame.js#L254)] - -| Parameters | Type | Description | Default | -| ----------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------- | -| data | Series or Dataframe | The data to dummify | | -| **options** | Object |

{

columns: Array of column names to dummify. If not specified, all categorical columns are encoded.

prefixSeparator: String separator for created columns e.g "_",

prefix: String | Array of String, of column names

}

| {**prefixSeparator**: "\_"} | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -### **Convert Series to Dummy codes** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let datasf = ['pear', 'mango', "pawpaw", "mango", "bean"] -let sf1 = new dfd.Series(datasf) - -let dum_df = dfd.get_dummies(sf1, { prefix: "fruit" }) -dum_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` - -╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ fruit_pear │ fruit_mango │ fruit_pawpaw │ fruit_bean ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 1 │ 0 │ 0 │ 0 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 0 │ 1 │ 0 │ 0 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 0 │ 0 │ 1 │ 0 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 0 │ 1 │ 0 │ 0 ║ -╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ 0 │ 0 │ 0 │ 1 ║ -╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### **Convert all categorical columns in a DataFrame to Dummy codes** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { fruits: ['pear', 'mango', "pawpaw", "mango", "bean"], - Count: [20, 30, 89, 12, 30], - Country: ["NG", "NG", "GH", "RU", "RU"]} - -let df = new dfd.DataFrame(data) -df.print() - -let dum_df = dfd.get_dummies(df) -dum_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ fruits │ Count │ Country ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ pear │ 20 │ NG ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ mango │ 30 │ NG ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ pawpaw │ 89 │ GH ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ mango │ 12 │ RU ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ bean │ 30 │ RU ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - //after dummification - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Count │ fruits_pear │ fruits_mango │ ... │ fruits_bean │ Country_NG │ Country_GH │ Country_RU ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 20 │ 1 │ 0 │ ... │ 0 │ 1 │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 30 │ 0 │ 1 │ ... │ 0 │ 1 │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 89 │ 0 │ 0 │ ... │ 0 │ 0 │ 1 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 12 │ 0 │ 1 │ ... │ 0 │ 0 │ 0 │ 1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ 30 │ 0 │ 0 │ ... │ 1 │ 0 │ 0 │ 1 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### **Convert a specific column in a DataFrame to Dummy codes** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { fruits: ['pear', 'mango', "pawpaw", "mango", "bean"], - Count: [20, 30, 89, 12, 30], - Country: ["NG", "NG", "GH", "RU", "RU"]} - -let df = new dfd.DataFrame(data) -df.print() - -let dum_df = dfd.get_dummies(df, { columns: ['fruits']}) -dum_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ fruits │ Count │ Country ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ pear │ 20 │ NG ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ mango │ 30 │ NG ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ pawpaw │ 89 │ GH ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ mango │ 12 │ RU ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ bean │ 30 │ RU ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - //after dummification - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Count │ Country │ fruits_pear │ fruits_mango │ fruits_pawpaw │ fruits_bean ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 20 │ NG │ 1 │ 0 │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 30 │ NG │ 0 │ 1 │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 89 │ GH │ 0 │ 0 │ 1 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 12 │ RU │ 0 │ 1 │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ 30 │ RU │ 0 │ 0 │ 0 │ 1 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -{% hint style="info" %} -See also [LabelEncoder](danfo.labelencoder.md) and [OneHotEncoder](danfo.onehotencoder.md) -{% endhint %} diff --git a/api-reference-v1-stable/general-functions/danfo.labelencoder.md b/api-reference-v1-stable/general-functions/danfo.labelencoder.md deleted file mode 100644 index b0745a8..0000000 --- a/api-reference-v1-stable/general-functions/danfo.labelencoder.md +++ /dev/null @@ -1,140 +0,0 @@ ---- -description: Encode target labels with value between 0 and n_classes-1. ---- - -# danfo.LabelEncoder - -class danfo.**LabelEncoder** \[[source](https://github.com/opensource9ja/danfojs/blob/fe56860b0a303d218d60ba71dee6abf594401556/danfojs/src/core/frame.js#L254)] - -danfo.js provides the LabelEncoder class for encoding Series and Arrays to integer between 0 and n\_classes -1. This is mostly used as a preprocessing step before most machine learning tasks. - -The API is similar to sklearn's [LabelEncoder](https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.LabelEncoder.html?highlight=labelencoder#sklearn.preprocessing.LabelEncoder), and provides a fit and transform method. - -## **Examples** - -### **Label Encode values in a Series** - -{% tabs %} -{% tab title="Node" %} -```javascript -let data = ["dog","cat","man","dog","cat","man","man","cat"] -let series = new dfd.Series(data) - -let encode = new dfd.LabelEncoder() - -encode.fit(series) -console.log(encode); - -let sf_enc = encode.transform(series.values) -sf_enc.print() - -let new_sf = encode.transform(["dog","man"]) -new_sf.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -LabelEncoder { label: [ 'dog', 'cat', 'man' ] } -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 0 ║ -╟───┼──────────────────────╢ -║ 1 │ 1 ║ -╟───┼──────────────────────╢ -║ 2 │ 2 ║ -╟───┼──────────────────────╢ -║ 3 │ 0 ║ -╟───┼──────────────────────╢ -║ 4 │ 1 ║ -╟───┼──────────────────────╢ -║ 5 │ 2 ║ -╟───┼──────────────────────╢ -║ 6 │ 2 ║ -╟───┼──────────────────────╢ -║ 7 │ 1 ║ -╚═══╧══════════════════════╝ - -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 0 ║ -╟───┼──────────────────────╢ -║ 1 │ 2 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -{% hint style="info" %} -**Labels not found in the original data used for fitting are represented with -1** -{% endhint %} - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { fruits: ['pear', 'mango', "pawpaw", "mango", "bean"] , - Count: [20, 30, 89, 12, 30], - Country: ["NG", "NG", "GH", "RU", "RU"]} - - -let df = new dfd.DataFrame(data) -let encode = new dfd.LabelEncoder() - -encode.fit(df['fruits']) -console.log(encode); - -let sf_enc = encode.transform(df['fruits'].values) -sf_enc.print() - -let new_sf = encode.transform(["mango","man"]) -new_sf.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -LabelEncoder { label: [ 'pear', 'mango', 'pawpaw', 'bean' ] } -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 0 ║ -╟───┼──────────────────────╢ -║ 1 │ 1 ║ -╟───┼──────────────────────╢ -║ 2 │ 2 ║ -╟───┼──────────────────────╢ -║ 3 │ 1 ║ -╟───┼──────────────────────╢ -║ 4 │ 3 ║ -╚═══╧══════════════════════╝ - -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 1 ║ -╟───┼──────────────────────╢ -║ 1 │ -1 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -See also [OneHotEncoder](danfo.onehotencoder.md) and[ danfo.get\_dummies](danfo.get\_dummies.md) diff --git a/api-reference-v1-stable/general-functions/danfo.merge.md b/api-reference-v1-stable/general-functions/danfo.merge.md deleted file mode 100644 index 0c4b760..0000000 --- a/api-reference-v1-stable/general-functions/danfo.merge.md +++ /dev/null @@ -1,453 +0,0 @@ ---- -description: >- - Merge DataFrame or named Series objects with a database-style join.The join is - done on columns or indexes. ---- - -# danfo.merge - -danfo.**merge**(kwargs) \[[source](https://github.com/opensource9ja/danfojs/blob/fe56860b0a303d218d60ba71dee6abf594401556/danfojs/src/core/frame.js#L254)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | -| **kwargs** | Object |

{

left: A DataFrame or named Series object.

right: Another DataFrame or named Series object.

on: Column names to join on. Must be found in both the left and right DataFrame and/or Series objects.

how: One of 'left','right','outer', 'inner'. Defaults to 'inner'

}

| {**how**: inner} | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -**danfo.js** merge function is similar to Pandas merge and performs in-memory join operations idiomatically very similar to relational databases like SQL. - -danfo.js provides a single function, [`merge()`](danfo.merge.md), as the entry point for all standard database join operations between `DataFrame` or named `Series` objects. - -For a more intuitive understanding, this [guide](https://pandas.pydata.org/pandas-docs/stable/user\_guide/merging.html#brief-primer-on-merge-methods-relational-algebra) on the [Pandas](https://pandas.pydata.org/pandas-docs/stable) doc is worth reading. - -### **Merging by a single key found in both axis** - -By default, danfo performs _**inner**_ join. An inner join requires each row in the two joined DataFrames to have matching column values. This is similar to the **intersection** of two sets. It returns a DataFrame with only those rows that have common characteristics. - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data = [['K0', 'k0', 'A0', 'B0'], ['k0', 'K1', 'A1', 'B1'], - ['K1', 'K0', 'A2', 'B2'], ['K2', 'K2', 'A3', 'B3']] - -let data2 = [['K0', 'k0', 'C0', 'D0'], ['K1', 'K0', 'C1', 'D1'], - ['K1', 'K0', 'C2', 'D2'], ['K2', 'K0', 'C3', 'D3']] - -let colum1 = ['Key1', 'Key2', 'A', 'B'] -let colum2 = ['Key1', 'Key2', 'A', 'D'] - -let df1 = new dfd.DataFrame(data, { columns: colum1 }) -let df2 = new dfd.DataFrame(data2, { columns: colum2 }) -df1.print() -df2.print() - -let merge_df = dfd.merge({ "left": df1, "right": df2, "on": ["Key1"]}) -merge_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` - - //first DataFrame -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Key1 │ Key2 │ A │ B ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ K0 │ k0 │ A0 │ B0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ k0 │ K1 │ A1 │ B1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ K1 │ K0 │ A2 │ B2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ K2 │ K2 │ A3 │ B3 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - //Second DataFrame - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Key1 │ Key2 │ A │ D ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ K0 │ k0 │ C0 │ D0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ K1 │ K0 │ C1 │ D1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ K1 │ K0 │ C2 │ D2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ K2 │ K0 │ C3 │ D3 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - //After inner join on column 'Key1' - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Key1 │ Key2 │ A │ B │ Key2_1 │ A_1 │ D ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ K0 │ k0 │ A0 │ B0 │ k0 │ C0 │ D0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ K1 │ K0 │ A2 │ B2 │ K0 │ C1 │ D1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ K1 │ K0 │ A2 │ B2 │ K0 │ C2 │ D2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ K2 │ K2 │ A3 │ B3 │ K0 │ C3 │ D3 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - -``` -{% endtab %} -{% endtabs %} - -### **Inner Join/Merge by multiple keys found in both axis** - -Merging by two keys takes into consideration the keys appearing in both`left` and `right DataFrame.` - -{% tabs %} -{% tab title="Node" %} -```javascript - -const dfd = require("danfojs-node") - - -let data = [['K0', 'k0', 'A0', 'B0'], ['k0', 'K1', 'A1', 'B1'], - ['K1', 'K0', 'A2', 'B2'], ['K2', 'K2', 'A3', 'B3']] - -let data2 = [['K0', 'k0', 'C0', 'D0'], ['K1', 'K0', 'C1', 'D1'], - ['K1', 'K0', 'C2', 'D2'], ['K2', 'K0', 'C3', 'D3']] - -let colum1 = ['Key1', 'Key2', 'A', 'B'] -let colum2 = ['Key1', 'Key2', 'A', 'D'] - -let df1 = new dfd.DataFrame(data, { columns: colum1 }) -let df2 = new dfd.DataFrame(data2, { columns: colum2 }) -df1.print() -df2.print() - -let merge_df = dfd.merge({ left: df1, right: df2, - on: ["Key1", 'Key2'], how: "inner"}) -merge_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -//first DataFrame -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Key1 │ Key2 │ A │ B ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ K0 │ k0 │ A0 │ B0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ k0 │ K1 │ A1 │ B1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ K1 │ K0 │ A2 │ B2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ K2 │ K2 │ A3 │ B3 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - - -//second DataFrame - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Key1 │ Key2 │ A │ D ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ K0 │ k0 │ C0 │ D0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ K1 │ K0 │ C1 │ D1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ K1 │ K0 │ C2 │ D2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ K2 │ K0 │ C3 │ D3 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - //After inner join on two keys - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Key1 │ Key2 │ A │ B │ A_1 │ D ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ K0 │ k0 │ A0 │ B0 │ C0 │ D0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ K1 │ K0 │ A2 │ B2 │ C1 │ D1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ K1 │ K0 │ A2 │ B2 │ C2 │ D2 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - -``` -{% endtab %} -{% endtabs %} - -The how parameter takes other types of joins like left, right and outer join and these are similar to their SQL equivalent - -### Outer join/merge on DataFrame - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data = [['K0', 'k0', 'A0', 'B0'], ['k0', 'K1', 'A1', 'B1'], - ['K1', 'K0', 'A2', 'B2'], ['K2', 'K2', 'A3', 'B3']] - -let data2 = [['K0', 'k0', 'C0', 'D0'], ['K1', 'K0', 'C1', 'D1'], - ['K1', 'K0', 'C2', 'D2'], ['K2', 'K0', 'C3', 'D3']] - -let colum1 = ['Key1', 'Key2', 'A', 'B'] -let colum2 = ['Key1', 'Key2', 'A', 'D'] - -let df1 = new dfd.DataFrame(data, { columns: colum1 }) -let df2 = new dfd.DataFrame(data2, { columns: colum2 }) -df1.print() -df2.print() - -let merge_df = dfd.merge({ left: df1, right: df2, - on: ["Key1"], how: "outer"}) -merge_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -//First DataFrame -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Key1 │ Key2 │ A │ B ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ K0 │ k0 │ A0 │ B0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ k0 │ K1 │ A1 │ B1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ K1 │ K0 │ A2 │ B2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ K2 │ K2 │ A3 │ B3 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - //Second DataFrame - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Key1 │ Key2 │ A │ D ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ K0 │ k0 │ C0 │ D0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ K1 │ K0 │ C1 │ D1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ K1 │ K0 │ C2 │ D2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ K2 │ K0 │ C3 │ D3 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - -//After outer join - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Key1 │ Key2 │ A │ B │ Key2_1 │ A_1 │ D ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ K0 │ k0 │ A0 │ B0 │ k0 │ C0 │ D0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ k0 │ K1 │ A1 │ B1 │ NaN │ NaN │ NaN ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ K1 │ K0 │ A2 │ B2 │ K0 │ C1 │ D1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ K1 │ K0 │ A2 │ B2 │ K0 │ C2 │ D2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ K2 │ K2 │ A3 │ B3 │ K0 │ C3 │ D3 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Left join/merge on DataFrame - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data = [['K0', 'k0', 'A0', 'B0'], ['k0', 'K1', 'A1', 'B1'], - ['K1', 'K0', 'A2', 'B2'], ['K2', 'K2', 'A3', 'B3']] - -let data2 = [['K0', 'k0', 'C0', 'D0'], ['K1', 'K0', 'C1', 'D1'], - ['K1', 'K0', 'C2', 'D2'], ['K2', 'K0', 'C3', 'D3']] - -let colum1 = ['Key1', 'Key2', 'A', 'B'] -let colum2 = ['Key1', 'Key2', 'A', 'D'] - -let df1 = new dfd.DataFrame(data, { columns: colum1 }) -let df2 = new dfd.DataFrame(data2, { columns: colum2 }) -df1.print() -df2.print() - -let merge_df = dfd.merge({ left: df1, right: df2, - on: ["Key1", "Key2"], how: "left"}) -merge_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -//first DataFrame -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Key1 │ Key2 │ A │ B ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ K0 │ k0 │ A0 │ B0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ k0 │ K1 │ A1 │ B1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ K1 │ K0 │ A2 │ B2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ K2 │ K2 │ A3 │ B3 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - - -//second DataFrame - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Key1 │ Key2 │ A │ D ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ K0 │ k0 │ C0 │ D0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ K1 │ K0 │ C1 │ D1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ K1 │ K0 │ C2 │ D2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ K2 │ K0 │ C3 │ D3 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - After left join -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Key1 │ Key2 │ A │ B │ A_1 │ D ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ K0 │ k0 │ A0 │ B0 │ C0 │ D0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ k0 │ K1 │ A1 │ B1 │ NaN │ NaN ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ K1 │ K0 │ A2 │ B2 │ C1 │ D1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ K1 │ K0 │ A2 │ B2 │ C2 │ D2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ K2 │ K2 │ A3 │ B3 │ NaN │ NaN ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Right join/merge on DataFrame - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data = [['K0', 'k0', 'A0', 'B0'], ['k0', 'K1', 'A1', 'B1'], - ['K1', 'K0', 'A2', 'B2'], ['K2', 'K2', 'A3', 'B3']] - -let data2 = [['K0', 'k0', 'C0', 'D0'], ['K1', 'K0', 'C1', 'D1'], - ['K1', 'K0', 'C2', 'D2'], ['K2', 'K0', 'C3', 'D3']] - -let colum1 = ['Key1', 'Key2', 'A', 'B'] -let colum2 = ['Key1', 'Key2', 'A', 'D'] - -let df1 = new dfd.DataFrame(data, { columns: colum1 }) -let df2 = new dfd.DataFrame(data2, { columns: colum2 }) -df1.print() -df2.print() - -let merge_df = dfd.merge({ left: df1, right: df2, - on: ["Key1", "Key2"], how: "right"}) -merge_df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -//first DataFrame -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Key1 │ Key2 │ A │ B ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ K0 │ k0 │ A0 │ B0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ k0 │ K1 │ A1 │ B1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ K1 │ K0 │ A2 │ B2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ K2 │ K2 │ A3 │ B3 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - //second DataFrame - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Key1 │ Key2 │ A │ D ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ K0 │ k0 │ C0 │ D0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ K1 │ K0 │ C1 │ D1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ K1 │ K0 │ C2 │ D2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ K2 │ K0 │ C3 │ D3 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - - -//after right join - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ Key1 │ Key2 │ A │ B │ A_1 │ D ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ K0 │ k0 │ A0 │ B0 │ C0 │ D0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ K1 │ K0 │ A2 │ B2 │ C1 │ D1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ K1 │ K0 │ A2 │ B2 │ C2 │ D2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ K2 │ K0 │ NaN │ NaN │ C3 │ D3 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -{% hint style="info" %} -See also [danfo.concat ](danfo.concat.md)for joining objects based on axis. -{% endhint %} diff --git a/api-reference-v1-stable/general-functions/danfo.minmaxscaler.md b/api-reference-v1-stable/general-functions/danfo.minmaxscaler.md deleted file mode 100644 index d58af8b..0000000 --- a/api-reference-v1-stable/general-functions/danfo.minmaxscaler.md +++ /dev/null @@ -1,125 +0,0 @@ ---- -description: Transform features by scaling each feature to a range of max and min values. ---- - -# danfo.MinMaxScaler - -class danfo.**MinMaxScaler** \[[source](https://github.com/opensource9ja/danfojs/blob/fe56860b0a303d218d60ba71dee6abf594401556/danfojs/src/core/frame.js#L254)] - -danfo.js provides the MinMaxScaler class for standardization of DataFrame and Series. This estimator scales and translates each feature individually such that it is in the given range on the training set, e.g. between zero and one. - -This transformation is often used as an alternative to zero mean, unit variance scaling like [Standardscaler](danfo.standardscaler.md). - -The API is similar to sklearn's [MinMaxScaler](https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.MinMaxScaler.html?highlight=minmaxscaler#sklearn.preprocessing.MinMaxScaler), and provides a fit and transform method. - -## **Examples** - -### Standardize DataFrame Object using MinMaxScaler - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let scaler = new dfd.MinMaxScaler() - -let data = [[100,1000,2000, 3000] , - [20, 30, 20, 10], - [1, 1, 1, 0]] - -let df = new dfd.DataFrame(data) -df.print() - -scaler.fit(df) - -let df_enc = scaler.transform(df) -df_enc.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ 0 │ 1 │ 2 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 100 │ 1000 │ 2000 │ 3000 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 20 │ 30 │ 20 │ 10 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 1 │ 1 │ 1 │ 0 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (3,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ 0 │ 1 │ 2 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 1 │ 1 │ 1 │ 1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 0.19191919267... │ 0.02902902849... │ 0.00950475223... │ 0.00333333341... ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 0 │ 0 │ 0 │ 0 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Standardize Series Object Using MinMaxScaler - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") -let scaler = new dfd.MinMaxScaler() - -let data = [[100,1000,2000, 3000] , - [20, 30, 20, 10], - [1, 1, 1, 0]] - -let df = new dfd.DataFrame(data) -let sf = df.iloc({columns: ["0"]}) - -scaler.fit(sf) - -let df_enc = scaler.transform(sf) -df_enc.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` - - Shape: (3,1) - -╔═══╤═══════════════════╗ -║ │ 0 ║ -╟───┼───────────────────╢ -║ 0 │ 1 ║ -╟───┼───────────────────╢ -║ 1 │ 0.19191919267... ║ -╟───┼───────────────────╢ -║ 2 │ 0 ║ -╚═══╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -See also [MinMaxScaler](danfo.minmaxscaler.md) diff --git a/api-reference-v1-stable/general-functions/danfo.onehotencoder.md b/api-reference-v1-stable/general-functions/danfo.onehotencoder.md deleted file mode 100644 index 81c913d..0000000 --- a/api-reference-v1-stable/general-functions/danfo.onehotencoder.md +++ /dev/null @@ -1,148 +0,0 @@ ---- -description: Encode categorical features as a one-hot numeric array. ---- - -# danfo.OneHotEncoder - -class danfo.**OneHotEncoder** \[[source](https://github.com/opensource9ja/danfojs/blob/e25010c26d9c423412613d820015a48ad03d5c6d/danfojs-node/src/preprocessing/encodings.js#L6)] - -danfo.js provides the OneHotEncoder class for encoding values in Series and Arrays to one-hot numeric arrays. This is mostly used as a preprocessing step before most machine learning tasks. - -The API is similar to scikit-learn's [OneHotEncoder](https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.OneHotEncoder.html?highlight=onehotencoder#sklearn.preprocessing.OneHotEncoder), and provides a fit and transform method. - -## **Examples** - -### **Convert Series to Dummy codes** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { fruits: ['pear', 'mango', "pawpaw", "mango", "bean"], - Count: [20, 30, 89, 12, 30], - Country: ["NG", "NG", "GH", "RU", "RU"]} - - -let df = new dfd.DataFrame(data) -let encode = new dfd.OneHotEncoder() - -encode.fit(df['fruits']) -console.log(encode); - -let sf_enc = encode.transform(df['fruits'].values) -sf_enc.print() - -let new_sf = encode.transform(["mango","bean"]) -new_sf.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ pear │ mango │ pawpaw │ bean ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 1 │ 0 │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 0 │ 1 │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 0 │ 0 │ 1 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 0 │ 1 │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ 0 │ 0 │ 0 │ 1 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (2,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ pear │ mango │ pawpaw │ bean ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 0 │ 1 │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 0 │ 0 │ 0 │ 1 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - -``` -{% endtab %} -{% endtabs %} - -{% hint style="info" %} -**Labels not found in the original data used for fitting are represented with 0s all through** -{% endhint %} - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { fruits: ['pear', 'mango', "pawpaw", "mango", "bean"] , - Count: [20, 30, 89, 12, 30], - Country: ["NG", "NG", "GH", "RU", "RU"]} - - -let df = new dfd.DataFrame(data) -let encode = new dfd.OneHotEncoder() - -encode.fit(df['fruits']) -console.log(encode); - -let sf_enc = encode.transform(df['fruits'].values) -sf_enc.print() - -let new_sf = encode.transform(["mango","woman", "cup"]) -new_sf.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ pear │ mango │ pawpaw │ bean ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 1 │ 0 │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 0 │ 1 │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 0 │ 0 │ 1 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 0 │ 1 │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ 0 │ 0 │ 0 │ 1 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (3,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ pear │ mango │ pawpaw │ bean ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 0 │ 1 │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 0 │ 0 │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 0 │ 0 │ 0 │ 0 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - -``` -{% endtab %} -{% endtabs %} - -See also [LabelEncoder](danfo.labelencoder.md) and[ danfo.get\_dummies](danfo.get\_dummies.md) diff --git a/api-reference-v1-stable/general-functions/danfo.standardscaler.md b/api-reference-v1-stable/general-functions/danfo.standardscaler.md deleted file mode 100644 index 89ce861..0000000 --- a/api-reference-v1-stable/general-functions/danfo.standardscaler.md +++ /dev/null @@ -1,132 +0,0 @@ ---- -description: Standardize features by removing the mean and scaling to unit variance. ---- - -# danfo.StandardScaler - -class danfo.**StandScaler** \[[source](https://github.com/opensource9ja/danfojs/blob/fe56860b0a303d218d60ba71dee6abf594401556/danfojs/src/core/frame.js#L254)] - -danfo.js provides the StandardScaler class for the standardization of DataFrame and Series. The standard score of a sample `x` is calculated as: - -> z = (x - u) / s - -where `u` is the mean of the training samples or zero if `with_mean=False`, and `s` is the standard deviation of the training samples or one if `with_std=False`. - -The API is similar to sklearn's [StandardScaler](https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.StandardScaler.html?highlight=standardscaler#sklearn.preprocessing.StandardScaler), and provides a fit and transform method. - -## **Examples** - -### Standardize Series Object - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let scaler = new dfd.StandardScaler() - -let sf = new dfd.Series([100,1000,2000, 3000]) -sf.print() - -scaler.fit(sf) - -let sf_enc = scaler.transform(sf) -sf_enc.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 100 ║ -╟───┼──────────────────────╢ -║ 1 │ 1000 ║ -╟───┼──────────────────────╢ -║ 2 │ 2000 ║ -╟───┼──────────────────────╢ -║ 3 │ 3000 ║ -╚═══╧══════════════════════╝ - -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ -1.1375757455825806 ║ -╟───┼──────────────────────╢ -║ 1 │ -0.4191068708896637 ║ -╟───┼──────────────────────╢ -║ 2 │ 0.37919193506240845 ║ -╟───┼──────────────────────╢ -║ 3 │ 1.1774907112121582 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Standardize DataFrame Object - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") -let scaler = new dfd.StandardScaler() - -let data = [[100,1000,2000, 3000] , - [20, 30, 89, 12], - [1, 1, 1, 0]] - -let df = new dfd.DataFrame(data) -df.print() - -scaler.fit(df) - -let df_enc = scaler.transform(df) -df_enc.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ 0 │ 1 │ 2 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 100 │ 1000 │ 2000 │ 3000 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 20 │ 30 │ 20 │ 10 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 1 │ 1 │ 1 │ 0 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (3,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ 0 │ 1 │ 2 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ -0.4185734987... │ 0.48862975835... │ 1.49663341045... │ 2.50463700294... ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ -0.4992137849... │ -0.4891337454319 │ -0.4992137849... │ -0.5092938542... ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ -0.5183658599... │ -0.5183658599... │ -0.5183658599... │ -0.5193738341... ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -See also [MinMaxScaler](danfo.minmaxscaler.md) diff --git a/api-reference-v1-stable/general-functions/danfo.to_datetime.md b/api-reference-v1-stable/general-functions/danfo.to_datetime.md deleted file mode 100644 index 7012100..0000000 --- a/api-reference-v1-stable/general-functions/danfo.to_datetime.md +++ /dev/null @@ -1,141 +0,0 @@ ---- -description: Converts an array of Date time string to Date object. ---- - -# danfo.toDateTime - -danfo.**toDateTime**(data) \[[source](https://github.com/opensource9ja/danfojs/blob/fe56860b0a303d218d60ba71dee6abf594401556/danfojs/src/core/frame.js#L254)] - -| Parameters | Type | Description | Default | -| ---------- | ------------- | ----------------------------------------------------------------------------------------------------------------- | ------- | -| **data** | Array, Series |

data: Array | Series with Date strings to convert to Date time.

| | - -**Returns:** - - **** return **DataFrame** - -## **Examples** - -Converts a **Series** of Date strings to Date time and get time properties - -{% tabs %} -{% tab title="Node" %} -```javascript -let data = new dfd.date_range({"start":'1/1/2018',period:12, freq:'M'}) -let sf = new dfd.Series(data) -sf.print() - -let dt = dfd.toDateTime(data) - -dt.month().print() -dt.month_name().print() -dt.weekdays().print() -dt.day().print() -dt.seconds().print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` - 0 -0 1/1/2018, 12:00:00 AM -1 2/1/2018, 12:00:00 AM -2 3/1/2018, 12:00:00 AM -3 4/1/2018, 12:00:00 AM -4 5/1/2018, 12:00:00 AM -5 6/1/2018, 12:00:00 AM -6 7/1/2018, 12:00:00 AM -7 8/1/2018, 12:00:00 AM -8 9/1/2018, 12:00:00 AM -9 10/1/2018, 12:00:00 AM -10 11/1/2018, 12:00:00 AM -11 12/1/2018, 12:00:00 AM - -//Int representation for month - 0 -0 0 -1 1 -2 2 -3 3 -4 4 -5 5 -6 6 -7 7 -8 8 -9 9 -10 10 -11 11 - -//string representation for month -0 -0 Jan -1 Feb -2 Mar -3 Apr -4 May -5 Jun -6 Jul -7 Aug -8 Sep -9 Oct -10 Nov -11 Dec - -//string representation for day of the week -0 -0 Mon -1 Thur -2 Thur -3 Sun -4 Tue -5 Fri -6 Sun -7 Wed -8 Sat -9 Mon -10 Thur -11 Sat - -0 -0 1 -1 4 -2 4 -3 0 -4 2 -5 5 -6 0 -7 3 -8 6 -9 1 -10 4 -11 6 - -//Hour of the day -0 -0 0 -1 0 -2 0 -3 0 -4 0 -5 0 -6 0 -7 0 -8 0 -9 0 -10 0 -11 0 - -``` -{% endtab %} -{% endtabs %} - -{% hint style="info" %} -Date time properties of Series or datetime-like columns in DataFrame can be accessed via accessors in the **dt** name-space. See [Accessors](https://app.gitbook.com/@jsdata/s/danfojs/\~/drafts/-MEMaWwva1cjt8CxnG-b/api-reference/series#accessors) -{% endhint %} diff --git a/api-reference-v1-stable/groupby.md b/api-reference-v1-stable/groupby.md deleted file mode 100644 index 1db2e52..0000000 --- a/api-reference-v1-stable/groupby.md +++ /dev/null @@ -1,122 +0,0 @@ ---- -description: >- - GroupBy objects are returned by groupby calls: danfo.DataFrame.groupby(), - danfo.Series.groupby() ---- - -# Groupby - -### Indexing, iteration - -| [`GroupBy.__iter__`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.__iter__.html#pandas.core.groupby.GroupBy.__iter__)\(\) | Groupby iterator. | -| :--- | :--- | -| [`GroupBy.groups`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.groups.html#pandas.core.groupby.GroupBy.groups) | Dict {group name -> group labels}. | -| [`GroupBy.indices`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.indices.html#pandas.core.groupby.GroupBy.indices) | Dict {group name -> group indices}. | -| [`GroupBy.get_group`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.get_group.html#pandas.core.groupby.GroupBy.get_group)\(name\[, obj\]\) | Construct DataFrame from group with provided name. | - -| [`Grouper`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Grouper.html#pandas.Grouper)\(\*args, \*\*kwargs\) | A Grouper allows the user to specify a groupby instruction for an object. | -| :--- | :--- | - - -### Function application - -| [`GroupBy.apply`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.apply.html#pandas.core.groupby.GroupBy.apply)\(func, \*args, \*\*kwargs\) | Apply function func group-wise and combine the results together. | -| :--- | :--- | -| [`GroupBy.agg`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.agg.html#pandas.core.groupby.GroupBy.agg)\(func, \*args, \*\*kwargs\) | | -| [`SeriesGroupBy.aggregate`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.SeriesGroupBy.aggregate.html#pandas.core.groupby.SeriesGroupBy.aggregate)\(\[func, engine, …\]\) | Aggregate using one or more operations over the specified axis. | -| [`DataFrameGroupBy.aggregate`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.aggregate.html#pandas.core.groupby.DataFrameGroupBy.aggregate)\(\[func, engine, …\]\) | Aggregate using one or more operations over the specified axis. | -| [`SeriesGroupBy.transform`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.SeriesGroupBy.transform.html#pandas.core.groupby.SeriesGroupBy.transform)\(func, \*args\[, …\]\) | Call function producing a like-indexed Series on each group and return a Series having the same indexes as the original object filled with the transformed values | -| [`DataFrameGroupBy.transform`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.transform.html#pandas.core.groupby.DataFrameGroupBy.transform)\(func, \*args\[, …\]\) | Call function producing a like-indexed DataFrame on each group and return a DataFrame having the same indexes as the original object filled with the transformed values | -| [`GroupBy.pipe`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.pipe.html#pandas.core.groupby.GroupBy.pipe)\(func, \*args, \*\*kwargs\) | Apply a function func with arguments to this GroupBy object and return the function’s result. | - -### Computations / descriptive stats - -| [`GroupBy.all`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.all.html#pandas.core.groupby.GroupBy.all)\(\[skipna\]\) | Return True if all values in the group are truthful, else False. | -| :--- | :--- | -| [`GroupBy.any`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.any.html#pandas.core.groupby.GroupBy.any)\(\[skipna\]\) | Return True if any value in the group is truthful, else False. | -| [`GroupBy.bfill`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.bfill.html#pandas.core.groupby.GroupBy.bfill)\(\[limit\]\) | Backward fill the values. | -| [`GroupBy.backfill`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.backfill.html#pandas.core.groupby.GroupBy.backfill)\(\[limit\]\) | Backward fill the values. | -| [`GroupBy.count`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.count.html#pandas.core.groupby.GroupBy.count)\(\) | Compute count of group, excluding missing values. | -| [`GroupBy.cumcount`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.cumcount.html#pandas.core.groupby.GroupBy.cumcount)\(\[ascending\]\) | Number each item in each group from 0 to the length of that group - 1. | -| [`GroupBy.cummax`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.cummax.html#pandas.core.groupby.GroupBy.cummax)\(\[axis\]\) | Cumulative max for each group. | -| [`GroupBy.cummin`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.cummin.html#pandas.core.groupby.GroupBy.cummin)\(\[axis\]\) | Cumulative min for each group. | -| [`GroupBy.cumprod`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.cumprod.html#pandas.core.groupby.GroupBy.cumprod)\(\[axis\]\) | Cumulative product for each group. | -| [`GroupBy.cumsum`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.cumsum.html#pandas.core.groupby.GroupBy.cumsum)\(\[axis\]\) | Cumulative sum for each group. | -| [`GroupBy.ffill`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.ffill.html#pandas.core.groupby.GroupBy.ffill)\(\[limit\]\) | Forward fill the values. | -| [`GroupBy.first`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.first.html#pandas.core.groupby.GroupBy.first)\(\[numeric\_only, min\_count\]\) | Compute first of group values. | -| [`GroupBy.head`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.head.html#pandas.core.groupby.GroupBy.head)\(\[n\]\) | Return first n rows of each group. | -| [`GroupBy.last`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.last.html#pandas.core.groupby.GroupBy.last)\(\[numeric\_only, min\_count\]\) | Compute last of group values. | -| [`GroupBy.max`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.max.html#pandas.core.groupby.GroupBy.max)\(\[numeric\_only, min\_count\]\) | Compute max of group values. | -| [`GroupBy.mean`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.mean.html#pandas.core.groupby.GroupBy.mean)\(\[numeric\_only\]\) | Compute mean of groups, excluding missing values. | -| [`GroupBy.median`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.median.html#pandas.core.groupby.GroupBy.median)\(\[numeric\_only\]\) | Compute median of groups, excluding missing values. | -| [`GroupBy.min`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.min.html#pandas.core.groupby.GroupBy.min)\(\[numeric\_only, min\_count\]\) | Compute min of group values. | -| [`GroupBy.ngroup`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.ngroup.html#pandas.core.groupby.GroupBy.ngroup)\(\[ascending\]\) | Number each group from 0 to the number of groups - 1. | -| [`GroupBy.nth`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.nth.html#pandas.core.groupby.GroupBy.nth)\(n\[, dropna\]\) | Take the nth row from each group if n is an int, or a subset of rows if n is a list of ints. | -| [`GroupBy.ohlc`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.ohlc.html#pandas.core.groupby.GroupBy.ohlc)\(\) | Compute open, high, low and close values of a group, excluding missing values. | -| [`GroupBy.pad`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.pad.html#pandas.core.groupby.GroupBy.pad)\(\[limit\]\) | Forward fill the values. | -| [`GroupBy.prod`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.prod.html#pandas.core.groupby.GroupBy.prod)\(\[numeric\_only, min\_count\]\) | Compute prod of group values. | -| [`GroupBy.rank`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.rank.html#pandas.core.groupby.GroupBy.rank)\(\[method, ascending, na\_option, …\]\) | Provide the rank of values within each group. | -| [`GroupBy.pct_change`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.pct_change.html#pandas.core.groupby.GroupBy.pct_change)\(\[periods, fill\_method, …\]\) | Calculate pct\_change of each value to previous entry in group. | -| [`GroupBy.size`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.size.html#pandas.core.groupby.GroupBy.size)\(\) | Compute group sizes. | -| [`GroupBy.sem`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.sem.html#pandas.core.groupby.GroupBy.sem)\(\[ddof\]\) | Compute standard error of the mean of groups, excluding missing values. | -| [`GroupBy.std`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.std.html#pandas.core.groupby.GroupBy.std)\(\[ddof\]\) | Compute standard deviation of groups, excluding missing values. | -| [`GroupBy.sum`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.sum.html#pandas.core.groupby.GroupBy.sum)\(\[numeric\_only, min\_count\]\) | Compute sum of group values. | -| [`GroupBy.var`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.var.html#pandas.core.groupby.GroupBy.var)\(\[ddof\]\) | Compute variance of groups, excluding missing values. | -| [`GroupBy.tail`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.tail.html#pandas.core.groupby.GroupBy.tail)\(\[n\]\) | Return last n rows of each group. | - -The following methods are available in both `SeriesGroupBy` and `DataFrameGroupBy` objects, but may differ slightly, usually in that the `DataFrameGroupBy` version usually permits the specification of an axis argument, and often an argument indicating whether to restrict application to columns of a specific data type. - -| [`DataFrameGroupBy.all`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.all.html#pandas.core.groupby.DataFrameGroupBy.all)\(\[skipna\]\) | Return True if all values in the group are truthful, else False. | -| :--- | :--- | -| [`DataFrameGroupBy.any`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.any.html#pandas.core.groupby.DataFrameGroupBy.any)\(\[skipna\]\) | Return True if any value in the group is truthful, else False. | -| [`DataFrameGroupBy.backfill`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.backfill.html#pandas.core.groupby.DataFrameGroupBy.backfill)\(\[limit\]\) | Backward fill the values. | -| [`DataFrameGroupBy.bfill`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.bfill.html#pandas.core.groupby.DataFrameGroupBy.bfill)\(\[limit\]\) | Backward fill the values. | -| [`DataFrameGroupBy.corr`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.corr.html#pandas.core.groupby.DataFrameGroupBy.corr) | Compute pairwise correlation of columns, excluding NA/null values. | -| [`DataFrameGroupBy.count`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.count.html#pandas.core.groupby.DataFrameGroupBy.count)\(\) | Compute count of group, excluding missing values. | -| [`DataFrameGroupBy.cov`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.cov.html#pandas.core.groupby.DataFrameGroupBy.cov) | Compute pairwise covariance of columns, excluding NA/null values. | -| [`DataFrameGroupBy.cumcount`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.cumcount.html#pandas.core.groupby.DataFrameGroupBy.cumcount)\(\[ascending\]\) | Number each item in each group from 0 to the length of that group - 1. | -| [`DataFrameGroupBy.cummax`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.cummax.html#pandas.core.groupby.DataFrameGroupBy.cummax)\(\[axis\]\) | Cumulative max for each group. | -| [`DataFrameGroupBy.cummin`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.cummin.html#pandas.core.groupby.DataFrameGroupBy.cummin)\(\[axis\]\) | Cumulative min for each group. | -| [`DataFrameGroupBy.cumprod`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.cumprod.html#pandas.core.groupby.DataFrameGroupBy.cumprod)\(\[axis\]\) | Cumulative product for each group. | -| [`DataFrameGroupBy.cumsum`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.cumsum.html#pandas.core.groupby.DataFrameGroupBy.cumsum)\(\[axis\]\) | Cumulative sum for each group. | -| [`DataFrameGroupBy.describe`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.describe.html#pandas.core.groupby.DataFrameGroupBy.describe)\(\*\*kwargs\) | Generate descriptive statistics. | -| [`DataFrameGroupBy.diff`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.diff.html#pandas.core.groupby.DataFrameGroupBy.diff) | First discrete difference of element. | -| [`DataFrameGroupBy.ffill`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.ffill.html#pandas.core.groupby.DataFrameGroupBy.ffill)\(\[limit\]\) | Forward fill the values. | -| [`DataFrameGroupBy.fillna`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.fillna.html#pandas.core.groupby.DataFrameGroupBy.fillna) | Fill NA/NaN values using the specified method. | -| [`DataFrameGroupBy.filter`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.filter.html#pandas.core.groupby.DataFrameGroupBy.filter)\(func\[, dropna\]\) | Return a copy of a DataFrame excluding filtered elements. | -| [`DataFrameGroupBy.hist`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.hist.html#pandas.core.groupby.DataFrameGroupBy.hist) | Make a histogram of the DataFrame’s. | -| [`DataFrameGroupBy.idxmax`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.idxmax.html#pandas.core.groupby.DataFrameGroupBy.idxmax) | Return index of first occurrence of maximum over requested axis. | -| [`DataFrameGroupBy.idxmin`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.idxmin.html#pandas.core.groupby.DataFrameGroupBy.idxmin) | Return index of first occurrence of minimum over requested axis. | -| [`DataFrameGroupBy.mad`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.mad.html#pandas.core.groupby.DataFrameGroupBy.mad) | Return the mean absolute deviation of the values for the requested axis. | -| [`DataFrameGroupBy.nunique`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.nunique.html#pandas.core.groupby.DataFrameGroupBy.nunique)\(\[dropna\]\) | Return DataFrame with counts of unique elements in each position. | -| [`DataFrameGroupBy.pad`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.pad.html#pandas.core.groupby.DataFrameGroupBy.pad)\(\[limit\]\) | Forward fill the values. | -| [`DataFrameGroupBy.pct_change`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.pct_change.html#pandas.core.groupby.DataFrameGroupBy.pct_change)\(\[periods, …\]\) | Calculate pct\_change of each value to previous entry in group. | -| [`DataFrameGroupBy.plot`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.plot.html#pandas.core.groupby.DataFrameGroupBy.plot) | Class implementing the .plot attribute for groupby objects. | -| [`DataFrameGroupBy.quantile`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.quantile.html#pandas.core.groupby.DataFrameGroupBy.quantile)\(\[q, interpolation\]\) | Return group values at the given quantile, a la numpy.percentile. | -| [`DataFrameGroupBy.rank`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.rank.html#pandas.core.groupby.DataFrameGroupBy.rank)\(\[method, ascending, …\]\) | Provide the rank of values within each group. | -| [`DataFrameGroupBy.resample`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.resample.html#pandas.core.groupby.DataFrameGroupBy.resample)\(rule, \*args, \*\*kwargs\) | Provide resampling when using a TimeGrouper. | -| [`DataFrameGroupBy.sample`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.sample.html#pandas.core.groupby.DataFrameGroupBy.sample)\(\[n, frac, replace, …\]\) | Return a random sample of items from each group. | -| [`DataFrameGroupBy.shift`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.shift.html#pandas.core.groupby.DataFrameGroupBy.shift)\(\[periods, freq, …\]\) | Shift each group by periods observations. | -| [`DataFrameGroupBy.size`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.size.html#pandas.core.groupby.DataFrameGroupBy.size)\(\) | Compute group sizes. | -| [`DataFrameGroupBy.skew`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.skew.html#pandas.core.groupby.DataFrameGroupBy.skew) | Return unbiased skew over requested axis. | -| [`DataFrameGroupBy.take`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.take.html#pandas.core.groupby.DataFrameGroupBy.take) | Return the elements in the given _positional_ indices along an axis. | -| [`DataFrameGroupBy.tshift`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.tshift.html#pandas.core.groupby.DataFrameGroupBy.tshift) | \(DEPRECATED\) Shift the time index, using the index’s frequency if available. | - -The following methods are available only for `SeriesGroupBy` objects. - -| [`SeriesGroupBy.hist`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.SeriesGroupBy.hist.html#pandas.core.groupby.SeriesGroupBy.hist) | Draw histogram of the input series using matplotlib. | -| :--- | :--- | -| [`SeriesGroupBy.nlargest`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.SeriesGroupBy.nlargest.html#pandas.core.groupby.SeriesGroupBy.nlargest) | Return the largest n elements. | -| [`SeriesGroupBy.nsmallest`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.SeriesGroupBy.nsmallest.html#pandas.core.groupby.SeriesGroupBy.nsmallest) | Return the smallest n elements. | -| [`SeriesGroupBy.nunique`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.SeriesGroupBy.nunique.html#pandas.core.groupby.SeriesGroupBy.nunique)\(\[dropna\]\) | Return number of unique elements in the group. | -| [`SeriesGroupBy.unique`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.SeriesGroupBy.unique.html#pandas.core.groupby.SeriesGroupBy.unique) | Return unique values of Series object. | -| [`SeriesGroupBy.value_counts`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.SeriesGroupBy.value_counts.html#pandas.core.groupby.SeriesGroupBy.value_counts)\(\[normalize, …\]\) | | -| [`SeriesGroupBy.is_monotonic_increasing`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.SeriesGroupBy.is_monotonic_increasing.html#pandas.core.groupby.SeriesGroupBy.is_monotonic_increasing) | Alias for is\_monotonic. | -| [`SeriesGroupBy.is_monotonic_decreasing`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.SeriesGroupBy.is_monotonic_decreasing.html#pandas.core.groupby.SeriesGroupBy.is_monotonic_decreasing) | Return boolean if values in the object are monotonic\_decreasing. | - -The following methods are available only for `DataFrameGroupBy` objects. - -| [`DataFrameGroupBy.corrwith`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.corrwith.html#pandas.core.groupby.DataFrameGroupBy.corrwith) | Compute pairwise correlation. | -| :--- | :--- | -| [`DataFrameGroupBy.boxplot`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.boxplot.html#pandas.core.groupby.DataFrameGroupBy.boxplot)\(\[subplots, column, …\]\) | Make box plots from DataFrameGroupBy data. | - diff --git a/api-reference-v1-stable/groupby/README.md b/api-reference-v1-stable/groupby/README.md deleted file mode 100644 index 9a1db65..0000000 --- a/api-reference-v1-stable/groupby/README.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -description: 'GroupBy objects are returned by groupby calls: danfo.DataFrame.groupby()' ---- - -# Groupby - -### Indexing, iteration - -| | | -| :--- | :--- | -| [`GroupBy.get_group`](groupby.get_groups.md) | Construct DataFrame from group with provided name. | - -### Function application - -| | | -| :--- | :--- | -| [`GroupBy.agg`](groupby.agg.md) | Aggregate using one or more operations over the specified axis. | - -### Computations / descriptive stats - -| | | -| :--- | :--- | -| [`GroupBy.count`](groupby.count.md) | Compute count of group, excluding missing values. | -| [`GroupBy.cummax`](groupby.cummax.md) | Cumulative max for each group. | -| [`GroupBy.cummin`](groupby.cummin.md) | Cumulative min for each group. | -| [`GroupBy.cumprod`](groupby.cumprod.md) | Cumulative product for each group. | -| [`GroupBy.cumsum`](groupby.cumsum.md) | Cumulative sum for each group. | -| [`GroupBy.max`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.max.html#pandas.core.groupby.GroupBy.max) | Compute max of group values. | -| [`GroupBy.mean`](groupby.mean.md) | Compute mean of groups, excluding missing values. | -| [`GroupBy.min`](groupby.min.md) | Compute min of group values. | -| [`GroupBy.std`](groupby.std.md) | Compute standard deviation of groups, excluding missing values. | -| [`GroupBy.sum`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.sum.html#pandas.core.groupby.GroupBy.sum) | Compute sum of group values. | -| [`GroupBy.var`](groupby.var.md) | Compute variance of groups, excluding missing values. | - diff --git a/api-reference-v1-stable/groupby/groupby.agg.md b/api-reference-v1-stable/groupby/groupby.agg.md deleted file mode 100644 index fae8802..0000000 --- a/api-reference-v1-stable/groupby/groupby.agg.md +++ /dev/null @@ -1,93 +0,0 @@ ---- -description: Obtain data aggregate per groups for each column ---- - -# Groupby.agg - -> danfo.Groupby.**agg**(kwargs) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L349)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | --------------------------------------------------------------------------------------------------------- | ------- | -| kwargs | Object | kwargs contain keys which are column names in the dataframe, and the values are operation to be performed | | - -**Return:** DataFrame - -**Examples** - -Using mean and sum aggregate - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A"]) -grp.agg({"C":"mean","D":"sum"}).print() -``` -{% endtab %} -{% endtabs %} - -``` - Shape: (2,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ C_mean │ D_sum ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 4.19999980926... │ 27 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ bar │ 3 │ 9 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Mean and Sum aggregate on dataframe groupby two column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A","B"]) -grp.agg({"C":"mean","D":"sum"}).print() -``` -{% endtab %} -{% endtabs %} - -``` - Shape: (5,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_mean │ D_sum ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 3.5 │ 10 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ two │ 3.5 │ 9 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ three │ 7 │ 8 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ bar │ one │ 3 │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ bar │ two │ 2 │ 6 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` diff --git a/api-reference-v1-stable/groupby/groupby.apply.md b/api-reference-v1-stable/groupby/groupby.apply.md deleted file mode 100644 index 2150a21..0000000 --- a/api-reference-v1-stable/groupby/groupby.apply.md +++ /dev/null @@ -1,84 +0,0 @@ ---- -description: Apply custom aggregate function to grouped data ---- - -# Groupby.apply - -danfo.Groupby.**apply**\(callable\) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs-node/src/core/groupby.js#L297)\] - -| Parameters | Type | Description | Default | -| :--- | :--- | :--- | :--- | -| callable | Function \| function to be applied to grouped data | Undefined | | - -**Returns:** - - ****return **DataFrame** - -## **Examples** - -Using apply to create a custom function that subtract the minimum value of each grouped data from each of its values - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - 'A': ['foo', 'bar', 'foo', 'bar', - - 'foo', 'bar', 'foo', 'foo'], - - 'B': ['one', 'one', 'two', 'three', - - 'two', 'two', 'one', 'three'], - - 'C': [1, 3, 2, 4, 5, 2, 6, 7], - - 'D': [3, 2, 4, 1, 5, 6, 7, 8] - }; -let df = new dfd.DataFrame(data); -let group_df = df.groupby(["A", "B"]); - -const subMin = (x) => { - return x.sub(x.min()); -}; - -group_df.apply(subMin).print(); - -``` -{% endtab %} - -{% tab title="Browser" %} -``` - -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```text -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_apply │ D_apply ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ one │ 5 │ 4 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ two │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ two │ 3 │ 1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ three │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 5 │ bar │ one │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 6 │ bar │ two │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 7 │ bar │ three │ 0 │ 0 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` -{% endtab %} -{% endtabs %} - -\*\*\*\* diff --git a/api-reference-v1-stable/groupby/groupby.col.md b/api-reference-v1-stable/groupby/groupby.col.md deleted file mode 100644 index 02e7cdd..0000000 --- a/api-reference-v1-stable/groupby/groupby.col.md +++ /dev/null @@ -1,105 +0,0 @@ ---- -description: Obtain the column(s) per groups ---- - -# Groupby.col - -> danfo.Groupby.col\(col\_names\) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L104)\] - -| Parameters | Type | Description | Default | -| :--- | :--- | :--- | :--- | -| col\_names | Array | List of column | | - -Returns: Groupby Data structure - -Note: This is similar to pandas `df.groupby(["column"])["col_names"]` - -**Examples** - -Obtain a column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - - -let grp = df.groupby(["A"]) -grp.col(["C"]) - -//for more coumns -grp.col(["C","D"]) -``` -{% endtab %} -{% endtabs %} - -Apparently the output are not that useful unless you perform some operations like max\(\), count\(\) and the likes. - -```text -//it returns the groupby data structure -GroupBy { - key_col: [ 'A' ], - col_dict: { - foo: [ [Array], [Array], [Array], [Array], [Array] ], - bar: [ [Array], [Array], [Array] ] - }, - data: [ - [ 'foo', 'one', 1, 3 ], - [ 'bar', 'one', 3, 2 ], - [ 'foo', 'two', 2, 4 ], - [ 'bar', 'three', 4, 1 ], - [ 'foo', 'two', 5, 5 ], - [ 'bar', 'two', 2, 6 ], - [ 'foo', 'one', 6, 7 ], - [ 'foo', 'three', 7, 8 ] - ], - column_name: [ 'A', 'B', 'C', 'D' ], - data_tensors: { - foo: DataFrame { - kwargs: [Object], - series: false, - data: [Array], - row_data_tensor: [Tensor], - index_arr: [Array], - columns: [Array], - col_data: [Array], - col_data_tensor: [Tensor], - col_types: [Array], - A: [Getter/Setter], - B: [Getter/Setter], - C: [Getter/Setter], - D: [Getter/Setter] - }, - bar: DataFrame { - kwargs: [Object], - series: false, - data: [Array], - row_data_tensor: [Tensor], - index_arr: [Array], - columns: [Array], - col_data: [Array], - col_data_tensor: [Tensor], - col_types: [Array], - A: [Getter/Setter], - B: [Getter/Setter], - C: [Getter/Setter], - D: [Getter/Setter] - } - }, - group_col_name: [ 'C' ], - group_col: { foo: [ [Series] ], bar: [ [Series] ] } -} -``` - - - diff --git a/api-reference-v1-stable/groupby/groupby.count.md b/api-reference-v1-stable/groupby/groupby.count.md deleted file mode 100644 index 36733be..0000000 --- a/api-reference-v1-stable/groupby/groupby.count.md +++ /dev/null @@ -1,175 +0,0 @@ ---- -description: Count the occurrence of values in columns per groups ---- - -# Groupby.count - -> danfo.Groupby.count() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L249)] - -**Parameters**: None - -**Return**: DataFrame - -**Examples** - -Obtain the variance of a column for each group, group by one column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - - -let grp = df.groupby(["A"]) -grp.col(["C"]).count().print() -``` -{% endtab %} -{% endtabs %} - -``` - - Shape: (2,2) - -╔═══╤═══════════════════╤═══════════════════╗ -║ │ A │ C_count ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 5 ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ bar │ 3 ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` - -Obtain the var for two columns for each group, group by one column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A"]) -grp.col(["C","D"]).count().print() -``` -{% endtab %} -{% endtabs %} - -``` - Shape: (2,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ C_count │ D_count ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 5 │ 5 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ bar │ 3 │ 3 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Obtain the count for a column for each group, group by two columns - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A","B"]) -grp.col(["C"]).count().print() - -``` -{% endtab %} -{% endtabs %} - -``` - Shape: (5,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_count ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ two │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ three │ 1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ bar │ one │ 1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ bar │ two │ 1 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Obtain the count for two columns for each group, group by two columns - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A","B"]) -grp.col(["C","D"]).count().print() -``` -{% endtab %} -{% endtabs %} - -``` - - Shape: (5,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_count │ D_count ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 2 │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ two │ 2 │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ three │ 1 │ 1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ bar │ one │ 1 │ 1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ bar │ two │ 1 │ 1 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -**** diff --git a/api-reference-v1-stable/groupby/groupby.cummax.md b/api-reference-v1-stable/groupby/groupby.cummax.md deleted file mode 100644 index 8231a61..0000000 --- a/api-reference-v1-stable/groupby/groupby.cummax.md +++ /dev/null @@ -1,258 +0,0 @@ ---- -description: Obtain the cummulative max per groups for each column ---- - -# Groupby.cummax - -> danfo.Groupby.cummax\(\) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L285)\] - -**Parameters**: None - -**Return**: DataFrame - -**Examples** - -Obtain the cumulative max of a column for each groups, group by one column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A"]) -grp.col(["C"]).cummax().head().print() -grp.col(["C"]).cummax().tail().print() -``` -{% endtab %} -{% endtabs %} - -```text - -Shape: (5,2) - -╔═══╤═══════════════════╤═══════════════════╗ -║ │ A │ C_cummax ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 1 ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ foo │ 2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ foo │ 5 ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ foo │ 6 ║ -╟───┼───────────────────┼───────────────────╢ -║ 4 │ foo │ 7 ║ -╚═══╧═══════════════════╧═══════════════════╝ - - - Shape: (5,2) - -╔═══╤═══════════════════╤═══════════════════╗ -║ │ A │ C_cummax ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ foo │ 6 ║ -╟───┼───────────────────┼───────────────────╢ -║ 4 │ foo │ 7 ║ -╟───┼───────────────────┼───────────────────╢ -║ 5 │ bar │ 3 ║ -╟───┼───────────────────┼───────────────────╢ -║ 6 │ bar │ 4 ║ -╟───┼───────────────────┼───────────────────╢ -║ 7 │ bar │ 4 ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` - -Obtain the cumsum for two columns for each group, group by one column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A"]) -grp.col(["C","D"]).cummax().head().print() -grp.col(["C","D"]).cummax().tail().print() -``` -{% endtab %} -{% endtabs %} - -```text - - Shape: (5,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ C_cummax │ D_cummax ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 1 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ 2 │ 4 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ 5 │ 5 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ 6 │ 7 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ 7 │ 8 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (5,3) - -╔════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ C_cummax │ D_cummax ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 11 │ bar │ 4 │ 2 ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 12 │ bar │ 4 │ 6 ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 13 │ bar │ 3 │ 2 ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 14 │ bar │ 4 │ 2 ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 15 │ bar │ 4 │ 6 ║ -╚════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Obtain the cummax for a column for each group, group by two columns - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A","B"]) -grp.col(["C"]).cummax().head().print() -grp.col(["C"]).cummax().tail().print() - -``` -{% endtab %} -{% endtabs %} - -```text - Shape: (5,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_cummax ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ one │ 6 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ two │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ two │ 5 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ three │ 7 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (5,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_cummax ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ two │ 5 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ three │ 7 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 5 │ bar │ one │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 6 │ bar │ two │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 7 │ bar │ three │ 4 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Obtain the cummax for two columns for each group, group by two columns - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A","B"]) -grp.col(["C","D"]).cummax().head().print() -grp.col(["C","D"]).cummax().tail().print() -``` -{% endtab %} -{% endtabs %} - -```text - - Shape: (5,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_cummax │ D_cummax ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 1 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ one │ 6 │ 7 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ two │ 2 │ 4 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ two │ 5 │ 5 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ three │ 7 │ 8 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (5,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_cummax │ D_cummax ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ two │ 5 │ 5 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ three │ 7 │ 8 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 5 │ bar │ one │ 3 │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 6 │ bar │ two │ 2 │ 6 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 7 │ bar │ three │ 4 │ 1 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - diff --git a/api-reference-v1-stable/groupby/groupby.cumprod.md b/api-reference-v1-stable/groupby/groupby.cumprod.md deleted file mode 100644 index af46123..0000000 --- a/api-reference-v1-stable/groupby/groupby.cumprod.md +++ /dev/null @@ -1,258 +0,0 @@ ---- -description: Obtain the cumulative product per group for each column ---- - -# Groupby.cumprod - -> danfo.Groupby.**cumprod**\(\) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L291)\] - -**Parameters**: None - -**Return**: DataFrame - -**Examples** - -Obtain the cumulative product of a column for each groups, group by one column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A"]) -grp.col(["C"]).cumprod().head().print() -grp.col(["C"]).cumprod().tail().print() -``` -{% endtab %} -{% endtabs %} - -```text - - Shape: (5,2) - -╔═══╤═══════════════════╤═══════════════════╗ -║ │ A │ C_cumprod ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 1 ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ foo │ 2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ foo │ 10 ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ foo │ 60 ║ -╟───┼───────────────────┼───────────────────╢ -║ 4 │ foo │ 420 ║ -╚═══╧═══════════════════╧═══════════════════╝ - - - Shape: (5,2) - -╔═══╤═══════════════════╤═══════════════════╗ -║ │ A │ C_cumprod ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ foo │ 60 ║ -╟───┼───────────────────┼───────────────────╢ -║ 4 │ foo │ 420 ║ -╟───┼───────────────────┼───────────────────╢ -║ 5 │ bar │ 3 ║ -╟───┼───────────────────┼───────────────────╢ -║ 6 │ bar │ 12 ║ -╟───┼───────────────────┼───────────────────╢ -║ 7 │ bar │ 24 ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` - -Obtain the cumprod for two columns for each groups, group by one column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A"]) -grp.col(["C","D"]).cumprod().head().print() -grp.col(["C","D"]).cumprod().tail().print() -``` -{% endtab %} -{% endtabs %} - -```text - -Shape: (5,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ C_cumprod │ D_cumprod ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 1 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ 2 │ 12 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ 10 │ 60 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ 60 │ 420 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ 420 │ 3360 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (5,3) - -╔════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ C_cumprod │ D_cumprod ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 11 │ bar │ 12 │ 2 ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 12 │ bar │ 24 │ 12 ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 13 │ bar │ 3 │ 2 ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 14 │ bar │ 12 │ 2 ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 15 │ bar │ 24 │ 12 ║ -╚════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Obtain the cumprod for a column for each group, group by two columns - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A","B"]) -grp.col(["C"]).cumprod().head().print() -grp.col(["C"]).cumprod().tail().print() - -``` -{% endtab %} -{% endtabs %} - -```text - Shape: (5,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_cumprod ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ one │ 6 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ two │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ two │ 10 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ three │ 7 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (5,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_cumprod ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ two │ 10 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ three │ 7 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 5 │ bar │ one │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 6 │ bar │ two │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 7 │ bar │ three │ 4 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Obtain the cumprod for two columns for each group, group by two columns - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A","B"]) -grp.col(["C","D"]).cumprod().head().print() -grp.col(["C","D"]).cumprod().tail().print() -``` -{% endtab %} -{% endtabs %} - -```text - - Shape: (5,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_cumprod │ D_cumprod ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 1 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ one │ 6 │ 21 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ two │ 2 │ 4 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ two │ 10 │ 20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ three │ 7 │ 8 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (5,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_cumprod │ D_cumprod ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ two │ 10 │ 20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ three │ 7 │ 8 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 5 │ bar │ one │ 3 │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 6 │ bar │ two │ 2 │ 6 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 7 │ bar │ three │ 4 │ 1 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - diff --git a/api-reference-v1-stable/groupby/groupby.cumsum.md b/api-reference-v1-stable/groupby/groupby.cumsum.md deleted file mode 100644 index 3b2b0e6..0000000 --- a/api-reference-v1-stable/groupby/groupby.cumsum.md +++ /dev/null @@ -1,259 +0,0 @@ ---- -description: Obtain the cumulative sum per groups for each column ---- - -# Groupby.cumsum - -> danfo.Groupby.**cumsum**() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L280)] - -**Parameters**: None - -**Return**: DataFrame - -**Examples** - -Obtain the cumulative sum of a column for each groups, group by one column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A"]) -grp.col(["C"]).cumsum().head().print() -grp.col(["C"]).cumsum().tail().print() -``` -{% endtab %} -{% endtabs %} - -``` - -Shape: (5,2) - -╔═══╤═══════════════════╤═══════════════════╗ -║ │ A │ C_cumsum ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 1 ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ foo │ 3 ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ foo │ 8 ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ foo │ 14 ║ -╟───┼───────────────────┼───────────────────╢ -║ 4 │ foo │ 21 ║ -╚═══╧═══════════════════╧═══════════════════╝ - - - Shape: (5,2) - -╔═══╤═══════════════════╤═══════════════════╗ -║ │ A │ C_cumsum ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ foo │ 14 ║ -╟───┼───────────────────┼───────────────────╢ -║ 4 │ foo │ 21 ║ -╟───┼───────────────────┼───────────────────╢ -║ 5 │ bar │ 3 ║ -╟───┼───────────────────┼───────────────────╢ -║ 6 │ bar │ 7 ║ -╟───┼───────────────────┼───────────────────╢ -║ 7 │ bar │ 9 ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` - -Obtain the cumsum for two columns for each group, group by one column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A"]) -grp.col(["C","D"]).cumsum().head().print() -grp.col(["C","D"]).cumsum().tail().print() -``` -{% endtab %} -{% endtabs %} - -``` - - Shape: (5,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ C_cumsum │ D_cumsum ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 1 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ 3 │ 7 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ 8 │ 12 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ 14 │ 19 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ 21 │ 27 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (5,3) - -╔════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ C_cumsum │ D_cumsum ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 11 │ bar │ 7 │ 3 ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 12 │ bar │ 9 │ 9 ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 13 │ bar │ 3 │ 2 ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 14 │ bar │ 7 │ 3 ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 15 │ bar │ 9 │ 9 ║ -╚════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Obtain the cumsum for a column for each group, group by two columns - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A","B"]) -grp.col(["C"]).cumsum().head().print() -grp.col(["C"]).cumsum().tail().print() - -``` -{% endtab %} -{% endtabs %} - -``` - Shape: (5,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_cumsum ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ one │ 7 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ two │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ two │ 7 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ three │ 7 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (5,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_cumsum ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ two │ 7 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ three │ 7 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 5 │ bar │ one │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 6 │ bar │ two │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 7 │ bar │ three │ 4 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Obtain the count for two columns for each group, group by two columns - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A","B"]) -grp.col(["C","D"]).cumsum().head().print() -grp.col(["C","D"]).cumsum().tail().print() -``` -{% endtab %} -{% endtabs %} - -``` - - Shape: (5,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_cumsum │ D_cumsum ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 1 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ one │ 7 │ 10 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ two │ 2 │ 4 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ two │ 7 │ 9 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ three │ 7 │ 8 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (5,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_cumsum │ D_cumsum ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ two │ 7 │ 9 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ three │ 7 │ 8 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 5 │ bar │ one │ 3 │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 6 │ bar │ two │ 2 │ 6 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 7 │ bar │ three │ 4 │ 1 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -**** diff --git a/api-reference-v1-stable/groupby/groupby.max.md b/api-reference-v1-stable/groupby/groupby.max.md deleted file mode 100644 index 43470f6..0000000 --- a/api-reference-v1-stable/groupby/groupby.max.md +++ /dev/null @@ -1,170 +0,0 @@ ---- -description: Obtain the maximum value of columns per groups ---- - -# Groupby.max - -> danfo.Groupby.max() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L309)] - -**Parameters:** None - -**Returns**: DataFrame - -**Example** - -Obtain the maximum value for a column for each group, group by one column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - - -let grp = df.groupby(["A"]) -grp.col(["C"]).max().print() -``` -{% endtab %} -{% endtabs %} - -``` - Shape: (2,2) - -╔═══╤═══════════════════╤═══════════════════╗ -║ │ A │ C_max ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 7 ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ bar │ 4 ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` - -Obtain the maximum value for two columns for each group, group by one column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - - -let grp = df.groupby(["A"]) -grp.col(["C","D"]).max().print() -``` -{% endtab %} -{% endtabs %} - -``` - Shape: (2,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ C_max │ D_max ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 7 │ 8 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ bar │ 4 │ 6 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Obtain the maximum value for a column for each group, group by two columns - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - - -let grp = df.groupby(["A","B"]) -grp.col(["C"]).max().print() -``` -{% endtab %} -{% endtabs %} - -``` - Shape: (5,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_max ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 6 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ two │ 5 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ three │ 7 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ bar │ one │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ bar │ two │ 2 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Obtain the maximum value for two columns for each group, group by two columns - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - - -let grp = df.groupby(["A","B"]) -grp.col(["C","D"]).max().print() -``` -{% endtab %} -{% endtabs %} - -``` - Shape: (5,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_max │ D_max ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 6 │ 7 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ two │ 5 │ 5 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ three │ 7 │ 8 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ bar │ one │ 3 │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ bar │ two │ 2 │ 6 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` diff --git a/api-reference-v1-stable/groupby/groupby.mean.md b/api-reference-v1-stable/groupby/groupby.mean.md deleted file mode 100644 index add6958..0000000 --- a/api-reference-v1-stable/groupby/groupby.mean.md +++ /dev/null @@ -1,173 +0,0 @@ ---- -description: Obtain the mean per groups for each column(s) ---- - -# Groupby.mean - -> danfo.Series.mean() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L274)] - -**Parameters**: None - -**Return**: DataFrame - -**Examples** - -Obtain the mean of a column for each group, group by one column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - - -let grp = df.groupby(["A"]) -grp.col(["C"]).mean().print() -``` -{% endtab %} -{% endtabs %} - -``` - - Shape: (2,2) - -╔═══╤═══════════════════╤═══════════════════╗ -║ │ A │ C_mean ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 4.19999980926... ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ bar │ 3 ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` - -Obtain the mean for two columns for each group, group by one column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - - -let grp = df.groupby(["A"]) -grp.col(["C","D"]).mean().print() -``` -{% endtab %} -{% endtabs %} - -``` - Shape: (2,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ C_mean │ D_mean ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 4.19999980926... │ 5.40000009536... ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ bar │ 3 │ 3 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Obtain the mean for a column for each group, group by two columns - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - - -let grp = df.groupby(["A","B"]) -grp.col(["C"]).mean().print() -``` -{% endtab %} -{% endtabs %} - -``` - Shape: (5,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_mean ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 3.5 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ two │ 3.5 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ three │ 7 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ bar │ one │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ bar │ two │ 2 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Obtain the mean for two columns for each group, group by two columns - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - - -let grp = df.groupby(["A","B"]) -grp.col(["C","D"]).mean().print() -``` -{% endtab %} -{% endtabs %} - -``` - Shape: (5,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_mean │ D_mean ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 3.5 │ 5 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ two │ 3.5 │ 4.5 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ three │ 7 │ 8 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ bar │ one │ 3 │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ bar │ two │ 2 │ 6 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -**** diff --git a/api-reference-v1-stable/groupby/groupby.min.md b/api-reference-v1-stable/groupby/groupby.min.md deleted file mode 100644 index 0151e64..0000000 --- a/api-reference-v1-stable/groupby/groupby.min.md +++ /dev/null @@ -1,171 +0,0 @@ ---- -description: Obtain the minimum value per groups for a coumn(s) ---- - -# Groupby.min - -> danfo.Groupby.min() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L315)] - -**Parameters**: None - -**Return**: DataFrame - -**Examples** - -Obtain the minimum value for a column for each group, group by one column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - - -let grp = df.groupby(["A"]) -grp.col(["C"]).min().print() -``` -{% endtab %} -{% endtabs %} - -``` - Shape: (2,2) - -╔═══╤═══════════════════╤═══════════════════╗ -║ │ A │ C_min ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 1 ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ bar │ 2 ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` - -Obtain the minimum value for two columns for each group, group by one column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - - -let grp = df.groupby(["A"]) -grp.col(["C","D"]).min().print() -``` -{% endtab %} -{% endtabs %} - -``` - Shape: (2,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ C_min │ D_min ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 1 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ bar │ 2 │ 1 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Obtain the maximum value for a column for each group, group by two columns - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - - -let grp = df.groupby(["A","B"]) -grp.col(["C"]).min().print() -``` -{% endtab %} -{% endtabs %} - -``` - Shape: (5,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_min ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ two │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ three │ 7 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ bar │ one │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ bar │ two │ 2 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Obtain the maximum value for two columns for each group, group by two columns - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - - -let grp = df.groupby(["A","B"]) -grp.col(["C","D"]).min().print() -``` -{% endtab %} -{% endtabs %} - -``` - Shape: (5,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_min │ D_min ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 1 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ two │ 2 │ 4 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ three │ 7 │ 8 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ bar │ one │ 3 │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ bar │ two │ 2 │ 6 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -**** diff --git a/api-reference-v1-stable/groupby/groupby.std.md b/api-reference-v1-stable/groupby/groupby.std.md deleted file mode 100644 index c792a8e..0000000 --- a/api-reference-v1-stable/groupby/groupby.std.md +++ /dev/null @@ -1,175 +0,0 @@ ---- -description: Obtain the standard deviation per groups for specified columns ---- - -# Groupby.std - -> danfo.Groupby.**std**() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L262)] - -**Parameters**: None - -**Return**: DataFrame - -**Examples** - -Obtain the standard deviation of a column for each group, group by one column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - - -let grp = df.groupby(["A"]) -grp.col(["C"]).std().print() -``` -{% endtab %} -{% endtabs %} - -``` - - Shape: (2,2) - -╔═══╤═══════════════════╤═══════════════════╗ -║ │ A │ C_std ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 2.58843582110... ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ bar │ 1 ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` - -Obtain the std for two columns for each group, group by one column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A"]) -grp.col(["C","D"]).std().print() -``` -{% endtab %} -{% endtabs %} - -``` - Shape: (2,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ C_std │ D_std ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 2.58843582110... │ 2.07364413533... ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ bar │ 1 │ 2.64575131106... ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Obtain the std for a column for each group, group by two columns - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A","B"]) -grp.col(["C"]).std().print() - -``` -{% endtab %} -{% endtabs %} - -``` - Shape: (5,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_std ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 3.53553390593... ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ two │ 2.12132034355... ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ three │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ bar │ one │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ bar │ two │ 0 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Obtain the std for two columns for each group, group by two columns - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A","B"]) -grp.col(["C","D"]).std().print() -``` -{% endtab %} -{% endtabs %} - -``` - - Shape: (5,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_std │ D_std ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 3.53553390593... │ 2.82842712474... ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ two │ 2.12132034355... │ 0.70710678118... ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ three │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ bar │ one │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ bar │ two │ 0 │ 0 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -**** diff --git a/api-reference-v1-stable/groupby/groupby.sum.md b/api-reference-v1-stable/groupby/groupby.sum.md deleted file mode 100644 index f6f2900..0000000 --- a/api-reference-v1-stable/groupby/groupby.sum.md +++ /dev/null @@ -1,172 +0,0 @@ ---- -description: Obtain the sum per groups for columns ---- - -# Groupby.sum - -> danfo.Groupby.sum() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L256)] - -**Parameters**: None - -**Return**: DataFrame - -**Examples** - -Obtain the sum of a column for each group, group by one column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - - -let grp = df.groupby(["A"]) -grp.col(["C"]).sum().print() -``` -{% endtab %} -{% endtabs %} - -``` - - Shape: (2,2) - -╔═══╤═══════════════════╤═══════════════════╗ -║ │ A │ C_sum ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 21 ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ bar │ 9 ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` - -Obtain the sum for two columns for each group, group by one column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - - -let grp = df.groupby(["A"]) -grp.col(["C","D"]).sum().print() -``` -{% endtab %} -{% endtabs %} - -``` - Shape: (2,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ C_sum │ D_sum ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 21 │ 27 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ bar │ 9 │ 9 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Obtain the sum for a column for each group, group by two columns - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - - -let grp = df.groupby(["A","B"]) -grp.col(["C"]).sum().print() -``` -{% endtab %} -{% endtabs %} - -``` - Shape: (5,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_sum ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 7 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ two │ 7 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ three │ 7 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ bar │ one │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ bar │ two │ 2 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Obtain the sum for two columns for each group, group by two columns - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - - -let grp = df.groupby(["A","B"]) -grp.col(["C","D"]).sum().print() -``` -{% endtab %} -{% endtabs %} - -``` - Shape: (5,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_sum │ D_sum ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 7 │ 10 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ two │ 7 │ 9 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ three │ 7 │ 8 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ bar │ one │ 3 │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ bar │ two │ 2 │ 6 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -**** diff --git a/api-reference-v1-stable/groupby/groupby.var.md b/api-reference-v1-stable/groupby/groupby.var.md deleted file mode 100644 index 373109f..0000000 --- a/api-reference-v1-stable/groupby/groupby.var.md +++ /dev/null @@ -1,175 +0,0 @@ ---- -description: Obtain the variance per groups for a specified column ---- - -# Groupby.var - -> danfo.Groupby.**var**() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L268)] - -**Parameters**: None - -**Return**: DataFrame - -**Examples** - -Obtain the variance of a column for each group, group by one column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - - -let grp = df.groupby(["A"]) -grp.col(["C"]).var().print() -``` -{% endtab %} -{% endtabs %} - -``` - - Shape: (2,2) - -╔═══╤═══════════════════╤═══════════════════╗ -║ │ A │ C_var ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 6.7 ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ bar │ 1 ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` - -Obtain the var for two columns for each group, group by one column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A"]) -grp.col(["C","D"]).var().print() -``` -{% endtab %} -{% endtabs %} - -``` - Shape: (2,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ C_var │ D_var ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 6.7 │ 4.3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ bar │ 1 │ 7 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Obtain the var for a column for each group, group by two columns - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A","B"]) -grp.col(["C"]).var().print() - -``` -{% endtab %} -{% endtabs %} - -``` - Shape: (5,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_var ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 12.5 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ two │ 4.5 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ three │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ bar │ one │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ bar │ two │ 0 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Obtain the var for two columns for each group, group by two columns - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A","B"]) -grp.col(["C","D"]).var().print() -``` -{% endtab %} -{% endtabs %} - -``` - - Shape: (5,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_var │ D_var ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 12.5 │ 8 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ two │ 4.5 │ 0.5 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ three │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ bar │ one │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ bar │ two │ 0 │ 0 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -**** diff --git a/api-reference-v1-stable/input-output/README.md b/api-reference-v1-stable/input-output/README.md deleted file mode 100644 index e86d5de..0000000 --- a/api-reference-v1-stable/input-output/README.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -description: Functions for reading tabular/structured data into DataFrame/Series Objects ---- - -# Input/Output - -## CSV - -| \`\` | | -| ----------------------------------- | -------------------------------------------------------- | -| [`read_csv`](danfo.read_csv.md) | Read a comma-separated values (csv) file into DataFrame. | -| [`read_excel`](danfo.read_excel.md) | Read an Excel values (xlsx) file into DataFrame. | -| [`read_json`](danfo.read_json.md) | Read a JSON values (json) file into DataFrame. | -| [to_csv](danfo.to_csv.md) | Writes a DataFrame/Series to CSV file | -| [to_excel](danfo.to_excel.md) | Writes a DataFrame/Series to Excel file | -| [to_json](danfo.to_json.md) | Writes a DataFrame/Series to JSON file | - -Writing to `CSV` and `JSON` can also be done directly from DataFrame or Series objects (e.g. [`DataFrame.to_csv()`](../dataframe/dataframe.to_csv.md)) diff --git a/api-reference-v1-stable/input-output/danfo.read_csv.md b/api-reference-v1-stable/input-output/danfo.read_csv.md deleted file mode 100644 index a291533..0000000 --- a/api-reference-v1-stable/input-output/danfo.read_csv.md +++ /dev/null @@ -1,134 +0,0 @@ ---- -description: >- - Reads a comma-separated values (CSV) file into DataFrame. Also supports the - reading of CSV files in chunks. ---- - -# danfo.read\_csv - -> danfo.**read\_csv**(source, configs) [\[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/io/reader.js#L21)] - -| | | | | -| -------------- | --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | -| **Parameters** | Type | Description | Default | -| _**source**_ | File object, File path, URL |

Any valid string path is acceptable. The string could be a URL or a valid local file path.

A browser input file object is also supported.

| | -| **configs**: | object, optional | Supports all Papaparse config parameters. See [https://www.papaparse.com/docs#config](https://www.papaparse.com/docs#config). |

{

dynamicTyping: true,

header: true

}

| - -**Returns:** - -\*\* \*\*_**Promise**_. Resolves to DataFrame - -The **read\_csv** method can read a CSV file from a local disk, or over the internet (URL). Reading of local files is only supported in Nodejs, while reading of input file objects is only supported in the browser. - -### **Reading files from local disk** - -By specifying a valid file path, you can load CSV files from local disk: - -{% tabs %} -{% tab title="Node.js" %} -```javascript -const dfd = require("danfojs-node") - -dfd.read_csv("./user_names.csv") //assumes file is in CWD - .then(df => { - - df.head().print() - - }).catch(err=>{ - console.log(err); - }) -``` -{% endtab %} -{% endtabs %} - -### **Reading files from a URL** - -By specifying a valid URL, you can load CSV files from any location into Danfo\*\*'\*\*s data structure: - -{% tabs %} -{% tab title="Node.js" %} -```javascript -const dfd = require("danfojs-node") - -dfd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv") //assumes file is in CWD - .then(df => { - - df.head().print() - - }).catch(err=>{ - console.log(err); - }) -``` -{% endtab %} - -{% tab title="Browser" %} -```markup - - - - - - - - - Document - - - - -
- - - - -``` -{% endtab %} -{% endtabs %} - -### **Reading an input file object in the browser** - -By specifying a valid [file object](https://developer.mozilla.org/en-US/docs/Web/API/File), you can load CSV files in the browser in DataFrames/Series - -{% tabs %} -{% tab title="Browser" %} -```markup - - - - - - - - Document - - - - - - - - -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/input-output/danfo.read_excel.md b/api-reference-v1-stable/input-output/danfo.read_excel.md deleted file mode 100644 index 459aa30..0000000 --- a/api-reference-v1-stable/input-output/danfo.read_excel.md +++ /dev/null @@ -1,68 +0,0 @@ ---- -description: Reads an excel file into DataFrame. ---- - -# danfo.read_excel - -> danfo.**read_excel**(source, configs) [\[source](https://github.com/opensource9ja/danfojs/blob/849d14c8e7fa79bce4ffa9d0d177639047313520/danfojs/src/io/reader.js#L89)] - -| Parameters | Type | Description | -| ---------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| source | string | **source** : string, URL or local file path to retreive Excel file. | -| configs | Object |

{

sheet : string, (Optional) Name of the sheet which u want to parse. Default will be the first sheet.
method: The HTTP method to use.

headers: Additional headers to send with the request if reading JSON from remote url. Supports all the node-fetch options in Nodejs, and all fetch options in browsers.

}

| - -> **Returns:** -> -> ** **return** **{**Promise**} DataFrame structure of parsed Excel data - -### Example - -The **read_excel** method can read excel files saved on a local disk, or over the internet. - -{% tabs %} -{% tab title="Node.js" %} -```javascript -const dfd = require("danfojs-node") -const path = require("path") - -let local_xcel = path.join(process.cwd(), "data", "testexcel.xlxs") - -async function load_process_data() { - let df = await dfd.read_excel(local_xcel) - df.head().print() -} - -load_process_data() -``` -{% endtab %} - -{% tab title="Browser" %} -```markup - - - - - - - - Document - - - - - - - - - -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/input-output/danfo.read_json.md b/api-reference-v1-stable/input-output/danfo.read_json.md deleted file mode 100644 index 3c17457..0000000 --- a/api-reference-v1-stable/input-output/danfo.read_json.md +++ /dev/null @@ -1,127 +0,0 @@ ---- -description: Reads a JSON file into DataFrame. ---- - -# danfo.read\_json - -> danfo.**read\_json**(source,) [\[source](https://github.com/opensource9ja/danfojs/blob/849d14c8e7fa79bce4ffa9d0d177639047313520/danfojs/src/io/reader.js#L47)] - -| | | | | -| -------------- | -------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- | -| **Parameters** | Type | Description | Default | -| _**source**_ | Input file object, string file\*\* \*\*path or URL |

Any valid string path is acceptable. The string could be a URL. Valid URL schemes include http, https, ftp, s3, gs, or a local path. Both relative and absolute paths are supported

An input file object is also supported in the browser.

| | -| options | Object |

Configuration options for reading JSON files. Supported options:

{
method: The HTTP method to use.

headers: Additional headers to send with the request if reading JSON from remote url. Supports all the node-fetch options in Nodejs, and all fetch options in browsers.

}

|

{
method: "GET"
}

| - -**Returns:** - -\*\* \*\*_**Promise**_. Resolves to DataFrame - -The **read\_json** method can read JSON files from a local disk, over the internet, or directly from input file objects. - -### **Reading JSON files from local disk** - -{% tabs %} -{% tab title="Node.js" %} -```javascript -const dfd = require("danfojs-node") - -dfd.read_json("./user_names.json") - .then(df => { - - df.head().print() - - }).catch(err=>{ - console.log(err); - }) -``` -{% endtab %} -{% endtabs %} - -### **Reading JSON files from a URL** - -By specifying a valid URL, you can load JSON files from any location: - -{% tabs %} -{% tab title="Node.js" %} -```javascript -const dfd = require("danfojs-node") - -dfd.read_json("https://raw.githubusercontentdatasets/master/finance-charts-apple.json") - .then(df => { - - df.head().print() - - }).catch(err=>{ - console.log(err); - }) -``` -{% endtab %} - -{% tab title="Browser" %} -```markup - - - - - - - - Document - - - - - - - - -``` -{% endtab %} -{% endtabs %} - -### **Reading an input file object in the browser** - -By specifying a valid [file object](https://developer.mozilla.org/en-US/docs/Web/API/File), you can load a JSON file in the browser: - -{% tabs %} -{% tab title="Browser" %} -```markup - - - - - - - - Document - - - - - - - - -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/input-output/danfo.to_csv.md b/api-reference-v1-stable/input-output/danfo.to_csv.md deleted file mode 100644 index c3403cf..0000000 --- a/api-reference-v1-stable/input-output/danfo.to_csv.md +++ /dev/null @@ -1,115 +0,0 @@ ---- -description: Writes a DataFrame or Series to CSV format. ---- - -# danfo.to\_csv - -> danfo.**to\_csv**(data, options) [\[source](https://github.com/opensource9ja/danfojs/blob/e25010c26d9c423412613d820015a48ad03d5c6d/danfojs-node/src/io/io.csv.js#L106)] - -| | | | | -| -------------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | -| **Parameters** | Type | Description | Default | -| _**data**_ | Series or DataFrame | The Series or DataFrame to write to CSV | | -| **options** | object, optional |

Configuration object:

{

filePath: Local file path to write the CSV file to. If not specified, the CSV will be returned as a string. Only needed in Nodejs version
fileName: The name of the file to download as. Only needed in browser environment.
download: Boolean indicating whether to automatically download the CSV file in the browser. Only needed in the browser environment.

header: Boolean indicating whether to include a header row in the CSV file.

sep: Character to be used as a separator in the CSV file.

}

|

{
download: true,
sep: ","

}

| - -The **to\_csv** function can be used to write out a DataFrame or Series to CSV file. The output is configurable and will depend on the environment. In the following examples, we show you how to write/download a CSV file from Node and Browser environments. - -### Convert DataFrame to CSV string and return value - -{% tabs %} -{% tab title="Node.js" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - Abs: [20.2, 30, 47.3], - Count: [34, 4, 5], - "country code": ["NG", "FR", "GH"], -}; - -let df = new dfd.DataFrame(data); - -const csv = dfd.to_csv(df, { download: false }); -console.log(csv); - -//output -Abs,Count,country code -20.2,34,NG -30,4,FR -47.3,5,GH -``` -{% endtab %} - -{% tab title="Browser" %} -```markup - - - - - - - - Document - - - - - - - - -``` -{% endtab %} -{% endtabs %} - -### Convert DataFrame to CSV string and write to file path - -Writing a CSV file to a local file path is only supported in the Nodejs environment - -{% tabs %} -{% tab title="Node.js" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - Abs: [20.2, 30, 47.3], - Count: [34, 4, 5], - "country code": ["NG", "FR", "GH"], -}; - -let df = new dfd.DataFrame(data); - -dfd.to_csv(df, { filePath: "testOut.csv"}); -``` -{% endtab %} -{% endtabs %} - -### Convert DataFrame to CSV string and download file in Client-side lib - -You can automatically convert and download a CSV file in a browser environment, by specifying a `fileName` and setting `download` to **true**. - -```javascript -const dfd = require("danfojs") - -let data = { - Abs: [20.2, 30, 47.3], - Count: [34, 4, 5], - "country code": ["NG", "FR", "GH"], -}; - -let df = new dfd.DataFrame(data); - -dfd.to_csv(df, { fileName: "testOut.csv", download: true}); -``` diff --git a/api-reference-v1-stable/input-output/danfo.to_excel.md b/api-reference-v1-stable/input-output/danfo.to_excel.md deleted file mode 100644 index 1fe1adf..0000000 --- a/api-reference-v1-stable/input-output/danfo.to_excel.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -description: >- - Converts a DataFrame or Series to Excel file and write file to disk or - download in browser. ---- - -# danfo.to_excel - -> danfo.**to_excel**(data, options) [\[source](https://github.com/opensource9ja/danfojs/blob/e25010c26d9c423412613d820015a48ad03d5c6d/danfojs-node/src/io/io.excel.js#L97)] - -| **Parameters** | Type | Description | Default | -| -------------- | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -| _**data**_ | Series or DataFrame | The Series or DataFrame to write to CSV | | -| **options** | object, optional |

Configuration object:

{

filePath: Local file path to write the CSV file to. If not specified, the CSV will be returned as a string. Only needed in Nodejs version
fileName: The name of the file to download as. Only needed in the browser environment.
sheetName: Name to call the excel sheet.

}

|

{
filePath: "./output.xlsx",
sheetName: "Sheet1"

}

| - -The **to_excel** function can be used to write out a DataFrame or Series to Excel (**.xlsx**) file. The output format will depend on the environment. In the following examples, we show you how to write/download an Excel file from Node and Browser environments. - -### Convert DataFrame to Excel and write to file path - -Writing an Excel file to a local file path is only supported in the Nodejs environment - -{% tabs %} -{% tab title="Node.js" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - Abs: [20.2, 30, 47.3], - Count: [34, 4, 5], - "country code": ["NG", "FR", "GH"], -}; - -let df = new dfd.DataFrame(data); - -dfd.to_excel(df, { filePath: "testOut.xlsx"}); -``` -{% endtab %} -{% endtabs %} - -### Convert DataFrame to Excel and download the file in Client-side lib - -You can automatically convert and download an Excel file in a browser environment, by specifying a `fileName`. - -```javascript -let data = { - Abs: [20.2, 30, 47.3], - Count: [34, 4, 5], - "country code": ["NG", "FR", "GH"], -}; - -let df = new dfd.DataFrame(data); - -dfd.to_excel(df, { fileName: "testOut.xlsx"}); -``` diff --git a/api-reference-v1-stable/input-output/danfo.to_json.md b/api-reference-v1-stable/input-output/danfo.to_json.md deleted file mode 100644 index baac615..0000000 --- a/api-reference-v1-stable/input-output/danfo.to_json.md +++ /dev/null @@ -1,124 +0,0 @@ -# danfo.to\_json - -> danfo.**to\_json**(data, options) [\[source](https://github.com/opensource9ja/danfojs/blob/e25010c26d9c423412613d820015a48ad03d5c6d/danfojs-node/src/io/io.json.js#L92)] - -| | | | | -| -------------- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- | -| **Parameters** | Type | Description | Default | -| _**data**_ | Series or DataFrame | The Series or DataFrame to write to CSV | | -| **options** | object, optional |

Configuration object:

{

filePath: Local file path to write the CSV file to. If not specified, the CSV will be returned as a string. Only needed in Nodejs version
fileName: The name of the file to download as. Only needed in browser environment.
format: The format of the JSON. Can be one of row or column.

}

|

{
format: "column"
}

| - -The **to\_json** function can be used to write out a DataFrame or Series to JSON format/file. The output is configurable and will depend on the environment. In the following examples, we show you how to write/download a JSON file from Node and Browser environments. - -### Convert DataFrame/Series to JSON and return value - -{% tabs %} -{% tab title="Node.js" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - Abs: [20.2, 30, 47.3], - Count: [34, 4, 5], - "country code": ["NG", "FR", "GH"], -}; - -let df = new dfd.DataFrame(data); - -const jsonObj = dfd.to_json(df, { download: false }); //column format -console.log(jsonObj); - -//output -[ - { Abs: 20.2, Count: 34, 'country code': 'NG' }, - { Abs: 30, Count: 4, 'country code': 'FR' }, - { Abs: 47.3, Count: 5, 'country code': 'GH' } -] - -//row format -const jsonObj = dfd.to_json(df, { - download: false, - format: "row" -}); - -console.log(jsonObj); -//output -{ - Abs: [ 20.2, 30, 47.3 ], - Count: [ 34, 4, 5 ], - 'country code': [ 'NG', 'FR', 'GH' ] -} -``` -{% endtab %} - -{% tab title="Browser" %} -```markup - - - - - - - - Document - - - - - - - - -``` -{% endtab %} -{% endtabs %} - -### Convert DataFrame/Series to JSON and write to file path - -Writing a DataFrame/Series as JSON, to a local file path is only supported in the Nodejs environment - -{% tabs %} -{% tab title="Node.js" %} -```javascript -const dfd = require("danfojs-node") - -let data = { - Abs: [20.2, 30, 47.3], - Count: [34, 4, 5], - "country code": ["NG", "FR", "GH"], -}; - -let df = new dfd.DataFrame(data); - -dfd.to_json(df, { filePath: "./testOutput.json" }); -``` -{% endtab %} -{% endtabs %} - -### Convert DataFrame/Series to JSON and download file in browser - -You can automatically convert and download a DataFrame/Series as a JSON file in a browser environment, by specifying a `fileName` and setting `download` to **true**. - -```javascript -let data = { - Abs: [20.2, 30, 47.3], - Count: [34, 4, 5], - "country code": ["NG", "FR", "GH"], -}; - -let df = new dfd.DataFrame(data); - -dfd.to_json(df, { fileName: "test_out.json" }); -``` diff --git a/api-reference-v1-stable/input-output/read.md b/api-reference-v1-stable/input-output/read.md deleted file mode 100644 index c38778e..0000000 --- a/api-reference-v1-stable/input-output/read.md +++ /dev/null @@ -1,138 +0,0 @@ ---- -description: >- - The generic read function loads a tabular data using the Frictionless - specification. ---- - -# read - -> danfo.**read**\(source, configs\) [\[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/io/reader.js#L21)\] - - - - - - - - - - - - - - - - - - - - - - - - -
Parameters - TypeDescriptionDefault
source - stringA path to the file/resources. It can be a local file, a URL to tabular - data (CSV, EXCEL) or Datahub.io Data Resource.
configs - object -

-

Configuration options. Supported params are:

-

data_num (Defaults => 0): The specific dataset to load, when - reading data from a datapackage.json,

-

header (Defaults => true): Whether the dataset contains a header - or not.

-

sheet (Defaults => 0): Number of the excel sheet which u want - to load.

-

}

-
- -**Returns:** - - ****_**Promise**_. Resolves to DataFrame - -The **read** function uses [frictionless.js](https://github.com/frictionlessdata/frictionless-js) underhood.[`frictionless.js`](https://github.com/frictionlessdata/frictionless-js) is a lightweight, standardized "stream-plus-metadata" interface for accessing files and datasets, especially tabular ones \(CSV, Excel\). It follows the [Frictionless spec](https://frictionlessdata.io/specs/) - -> ### **Note**: The `read` method is only available in danfojs-node at the moment. - -### Read a CSV file - -{% tabs %} -{% tab title="Node.js" %} -```javascript -const dfd = require("danfojs-node") - -async function load_data() { - let df = await dfd.read("file.csv") - let sample = await df.sample(10) - sample.print() -} - -load_data() -``` -{% endtab %} -{% endtabs %} - -### **Loading Files from URL** - -By specifying a valid URL, you can load CSV/EXCEL file: - -{% tabs %} -{% tab title="Node.js" %} -```javascript -const dfd = require("danfojs-node") - -async function load_data() { - let df = await dfd.read("https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv") - df.head().print() -} - -load_data() -``` -{% endtab %} -{% endtabs %} - -### Loading Data from a Data Package Descriptor - -You can load data from a frictionless data package [descriptor](https://specs.frictionlessdata.io/data-package/#descriptor). A data package descriptor is a central file in a Data Package. It is a JSON file that provides: - -* General metadata such as the package’s title, license, publisher etc -* A list of the data “resources” that make up the package including their location on disk or online and other relevant information \(including, possibly, schema information about these data resources in a structured form\) - -For instance, in the example below, we load the first resource in the [Natural Gas dataset](https://datahub.io/core/natural-gas) from datahub.io. - -{% tabs %} -{% tab title="JavaScript" %} -```javascript -const dfd = require("danfojs-node") - -async function load_data() { - const package_url = - "https://datahub.io/core/natural-gas/datapackage.json"; - - const df = await dfd.read(package_url, { data_num: 1 }); - df.head().print(); - -load_data() -``` -{% endtab %} -{% endtabs %} - -```bash -╔═══╤═══════════════════╤═══════════════════╗ -║ │ Date │ Price ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ 1997-01-07 │ 3.81999999999... ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ 1997-01-08 │ 3.79999999999... ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ 1997-01-09 │ 3.60999999999... ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ 1997-01-10 │ 3.91999999999... ║ -╟───┼───────────────────┼───────────────────╢ -║ 4 │ 1997-01-13 │ 4 ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` - - - diff --git a/api-reference-v1-stable/plotting/README.md b/api-reference-v1-stable/plotting/README.md deleted file mode 100644 index 93161e3..0000000 --- a/api-reference-v1-stable/plotting/README.md +++ /dev/null @@ -1,19 +0,0 @@ ---- -description: >- - DataFrame and Series have inbuilt support for plotting using Plotly's backend. - All customization can be done using Plotly's parameter passed to the config - object. ---- - -# Plotting - -* [Line Charts](line-charts.md) -* [Bar Charts](bar-charts.md) -* [Scatter Plots](scatter-plots.md) -* [Histograms](histograms.md) -* [Pie Charts](pie-charts.md) -* [Tables](tables.md) -* [Box Plots](box-plots.md) -* [Violin Plots](violin-plots.md) -* [Timeseries Plots](timeseries-plots.md) - diff --git a/api-reference-v1-stable/plotting/bar-charts.md b/api-reference-v1-stable/plotting/bar-charts.md deleted file mode 100644 index 6606bdc..0000000 --- a/api-reference-v1-stable/plotting/bar-charts.md +++ /dev/null @@ -1,75 +0,0 @@ ---- -description: Makes a vertical bar plot. ---- - -# Bar Charts - -A bar plot presents categorical data with rectangular bars with lengths proportional to the values that they represent. - -## Examples - -The **bar** plot is exposed by the .**plot()** function called on a Series or DataFrame. The **.plot()** method accepts an HTML Div id where it renders the plot, while configuration options for the bars drawn can be passed through the config parameter. - -### Bar plot on Series - -```markup - - - - - - - - - Document - - - - -
- - - - -``` - -![](<../../.gitbook/assets/newplot (6).png>) - -### Bar plot on DataFrame - -```markup - - - - - - - - - - - - -
- - - - -``` - -![](<../../.gitbook/assets/newplot (7).png>) - -{% hint style="info" %} -To set configuration for your plots, see the [Configuring your plot page](configuring-your-plots.md) -{% endhint %} diff --git a/api-reference-v1-stable/plotting/box-plots.md b/api-reference-v1-stable/plotting/box-plots.md deleted file mode 100644 index 2adb60a..0000000 --- a/api-reference-v1-stable/plotting/box-plots.md +++ /dev/null @@ -1,116 +0,0 @@ ---- -description: Make a box plot from DataFrame columns. ---- - -# Box Plots - -Make a box-and-whisker plot from DataFrame columns, optionally grouped by some other columns. A box plot is a method for graphically depicting groups of numerical data through their quartiles. - -## Examples - -### Boxplot for a Series Object - -```markup - - - - - - - - - Document - - - - -
- - - - -``` - -![](<../../.gitbook/assets/newplot (23).png>) - -### Box plots on a DataFrame - -```markup - - - - - - - - - Document - - - - -
- - - - -``` - -![](<../../.gitbook/assets/screen-shot-2020-08-11-at-1.20.42-am (1).png>) - -### Box plot for selected columns in a DataFrame - -```markup - - - - - - - - - Document - - - - -
- - - - -``` - -![](<../../.gitbook/assets/newplot (24).png>) - -{% hint style="info" %} -To set configuration for your plots, see the [Configuring your plot page](configuring-your-plots.md) -{% endhint %} diff --git a/api-reference-v1-stable/plotting/configuring-your-plots.md b/api-reference-v1-stable/plotting/configuring-your-plots.md deleted file mode 100644 index 4cedbb2..0000000 --- a/api-reference-v1-stable/plotting/configuring-your-plots.md +++ /dev/null @@ -1,68 +0,0 @@ -# Configuring your plots - -danfo.js plotting uses [Plotly.js](https://plotly.com/javascript) as its backend for plotting. This means you have all the configuration, flexibility and interactiveness of Plotly. - -All [customization](https://plotly.com/javascript/line-charts/) on the plot can be passed as an object of key-value pairs to the config parameter. For example, in the line plot below, we define a layout for our plot and give it a name. - -For example in the following code, we show how to set some basic configuration as well as layout for a line plot. - -```markup - - - - - - - - - - - -
- - - - -``` - -![](<../../.gitbook/assets/newplot (32).png>) diff --git a/api-reference-v1-stable/plotting/histograms.md b/api-reference-v1-stable/plotting/histograms.md deleted file mode 100644 index adabd84..0000000 --- a/api-reference-v1-stable/plotting/histograms.md +++ /dev/null @@ -1,117 +0,0 @@ ---- -description: Draw one histogram of the DataFrame’s columns, or single histogram for Series ---- - -# Histograms - -A histogram is a representation of the distribution of data. This function groups the values of all given Series in the DataFrame into bins - -## Examples - -### Histogram of a Column in a DataFrame - -In the example below, we use the titanic dataset, to show a close to a real-world use case of danfo.js - -```markup - - - - - - - - - Document - - - - -
- - - - -``` - -![](<../../.gitbook/assets/newplot (10).png>) - -### Customized Histogram plots on DataFrame - -```markup - - - - - - - - - Document - - - - -
- - - - -``` - -![](<../../.gitbook/assets/newplot (20).png>) - -### Configuring your plots - -danfo.js plotting uses [Plotly.js](https://plotly.com/javascript) as its backend for plotting. This means you have all the configuration, flexibility and interactiveness of Plotly. - -All [customization](https://plotly.com/javascript/line-charts/) on the plot can be passed as an object of key-value pairs to the config parameter. For example: - -```javascript -var layout = { - title: 'A sample plot', - xaxis: { - title: 'X', - }, - yaxis: { - title: 'Y', - } -} - -df.plot("div_tag").histogram({layout: layout}) -``` - -{% hint style="info" %} -For more configuration options for Histograms, see the [Plotly](https://plotly.com/javascript/histograms/) style doc. -{% endhint %} diff --git a/api-reference-v1-stable/plotting/line-charts.md b/api-reference-v1-stable/plotting/line-charts.md deleted file mode 100644 index 79fe4d3..0000000 --- a/api-reference-v1-stable/plotting/line-charts.md +++ /dev/null @@ -1,109 +0,0 @@ ---- -description: >- - Plot Series or DataFrame as lines. This function is useful to plot lines using - DataFrame’s values as coordinates. ---- - -# Line Charts - -## Examples - -### Basic Line plot on Series - -The **line** plot is exposed by the .**plot()** function called on a Series or DataFrame. The **.plot()** method accepts an HTML Div id where it renders the plot, while configuration options for the lines drawn can be passed through the config parameter. - -```markup - - - - - - - - - Document - - - - -
- - - - -``` - -![](<../../.gitbook/assets/newplot (4).png>) - -### Line plots on DataFrame - -The example below shows the plot of column values against a common x-axis (index) - -```markup - - - - - - - - - Document - - - - -
- - - - -``` - -![](<../../.gitbook/assets/newplot (2).png>) - -The example below shows how to plot two columns in a DataFrame against each other. - -```markup - - - - - - - - - Document - - - - -
- - - - -``` - -![](<../../.gitbook/assets/newplot (3).png>) - -{% hint style="info" %} -To set configuration for your plots, see the [Configuring your plot page](configuring-your-plots.md) -{% endhint %} diff --git a/api-reference-v1-stable/plotting/pie-charts.md b/api-reference-v1-stable/plotting/pie-charts.md deleted file mode 100644 index 6dce73d..0000000 --- a/api-reference-v1-stable/plotting/pie-charts.md +++ /dev/null @@ -1,123 +0,0 @@ ---- -description: Generate a pie plot. ---- - -# Pie Charts - -A pie plot is a proportional representation of the numerical data in a column - -## Examples - -### Pie Chart from Columns in a DataFrame - -```markup - - - - - - - - - Document - - - - -
- - - - -``` - -![](<../../.gitbook/assets/newplot (12).png>) - -### Multiple Pie Chart from Columns in a DataFrame - -```markup - - - - - - - - - Document - - - - -
- - - - -``` - -![](<../../.gitbook/assets/newplot (21).png>) - -### Configure Position of Pie Charts - -If you have more than one pie charts displayed, you can set the grid parameter, and also the position of each pie. For example, in the snippet below, we set our grid to 2 by 2 and also pass a set of row and column index position. Each row/column position index correspond to each pie. - -```markup - - - - - - - - - Document - - - - -
- - - - -``` - -![](<../../.gitbook/assets/newplot (22).png>) - -{% hint style="info" %} -For more configuration options for Pie Charts, see the [Plotly](https://plotly.com/javascript/pie-charts/) style doc. -{% endhint %} diff --git a/api-reference-v1-stable/plotting/scatter-plots.md b/api-reference-v1-stable/plotting/scatter-plots.md deleted file mode 100644 index 77649d1..0000000 --- a/api-reference-v1-stable/plotting/scatter-plots.md +++ /dev/null @@ -1,88 +0,0 @@ ---- -description: Create a scatter plot of columns in a DataFrame ---- - -# Scatter Plots - -The coordinates of each point are defined by two DataFrame columns and filled circles are used to represent each point. Scatter plot is useful for visualizing complex correlations between two variables. - -## Examples - -### Scatter Plots on Columns in a DataFrame - -In the example below, we use the titanic dataset, to show a close to real-world use case of danfo.js - -```markup - - - - - - - - - Document - - - - -
- - - - -``` - -![](<../../.gitbook/assets/newplot-8- (1) (1).png>) - -### More Examples - -```markup - - - - - - - - - Document - - - - -
- - - - -``` - -![](<../../.gitbook/assets/newplot (19).png>) - -{% hint style="info" %} -To set configuration for your plots, see the [Configuring your plot page](configuring-your-plots.md) -{% endhint %} diff --git a/api-reference-v1-stable/plotting/tables.md b/api-reference-v1-stable/plotting/tables.md deleted file mode 100644 index c67f0e2..0000000 --- a/api-reference-v1-stable/plotting/tables.md +++ /dev/null @@ -1,95 +0,0 @@ ---- -description: Turn DataFrame/Series in D3.js-based tables ---- - -# Tables - -## Examples - -### Create Interactive Tables from DataFrame - -```markup - - - - - - - - - Document - - - - -
- - - - -``` - -![](<../../.gitbook/assets/Screen Shot 2020-08-11 at 12.34.08 AM.png>) - -### Configure the header and cell of a table - -To configure the header and cell of a table, you can pass header/cell styles to the **header\_style** and **cell\_style** parameter. The [Plotly table](https://plotly.com/javascript/table/) doc shows numerous configuration options you can pass. - -```markup - - - - - - - - - Document - - - - -
- - - - - -``` - -![](<../../.gitbook/assets/Screen Shot 2020-08-11 at 12.38.30 AM.png>) diff --git a/api-reference-v1-stable/plotting/timeseries-plots.md b/api-reference-v1-stable/plotting/timeseries-plots.md deleted file mode 100644 index 7bbb089..0000000 --- a/api-reference-v1-stable/plotting/timeseries-plots.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -description: Timeseries plot are based on date index ---- - -# Timeseries Plots - -## Examples - -In the example below, we plot the yearly trend of a financial dataset. First, we reset the index to the Date column. - -```markup - - - - - - - - - Document - - - - -
- - - - -``` - -![](<../../.gitbook/assets/newplot-29- (2) (1).png>) - -{% hint style="info" %} -To set configuration for your plots, see the [Configuring your plot page](configuring-your-plots.md) -{% endhint %} diff --git a/api-reference-v1-stable/plotting/violin-plots.md b/api-reference-v1-stable/plotting/violin-plots.md deleted file mode 100644 index a3e6c11..0000000 --- a/api-reference-v1-stable/plotting/violin-plots.md +++ /dev/null @@ -1,112 +0,0 @@ -# Violin Plots - -Make a violin plot from DataFrame columns, optionally grouped by some other columns. A violin plot is a method for graphically depicting groups of numerical data through their quartiles. See also [Box Plot](box-plots.md) - -## Examples - -### Boxplot for a Series Object - -```markup - - - - - - - - - Document - - - - -
- - - - -``` - -![](<../../.gitbook/assets/newplot (25).png>) - -### Box plots on a DataFrame - -```markup - - - - - - - - - Document - - - - -
- - - - -``` - -![](<../../.gitbook/assets/newplot (26).png>) - -### Box plot for selected columns in a DataFrame - -```markup - - - - - - - - - Document - - - - -
- - - - -``` - -![](<../../.gitbook/assets/newplot (27).png>) - -{% hint style="info" %} -To set configuration for your plots, see the [Configuring your plot page](configuring-your-plots.md) -{% endhint %} diff --git a/api-reference-v1-stable/series/README.md b/api-reference-v1-stable/series/README.md deleted file mode 100644 index 421bc63..0000000 --- a/api-reference-v1-stable/series/README.md +++ /dev/null @@ -1,182 +0,0 @@ ---- -description: One-dimensional ndarray with axis labels (including time series). ---- - -# Series - -> `Series`(data, {**columns:** \[ Array ], **dtypes:** \[ Array ], **index:** \[Array]}) \[[source](https://github.com/opensource9ja/danfojs/blob/3398c2f540c16ac95599a05b6f2db4eff8a258c9/danfojs/src/core/series.js#L28)] - -### Attributes - -| [`Series.index`](series.index.md) | The index (axis labels) of the Series. | -| --------------------------------- | ------------------------------------------- | - -| [`Series.tensor`](series.tensor.md) | The Tensorflow tensor of the data backing this Series or Index. | -| ----------------------------------- | ---------------------------------------------------------------- | -| [`Series.values`](series.values.md) | Return Series as ndarray or ndarray-like depending on the dtype. | -| [`Series.dtype`](series.dtype.md) | Return the dtype object of the underlying data. | -| [`Series.shape`](series.shape.md) | Return a tuple of the shape of the underlying data. | -| [`Series.ndim`](series.ndim.md) | Number of dimensions of the underlying data, by definition 1. | -| [`Series.size`](broken-reference) | Return the number of elements in the underlying data. | - -### Conversion - -| [`Series.astype`](../dataframe/dataframe.astype.md) | Cast a Series object to a specified dtype | -| --------------------------------------------------- | ---------------------------------------------- | -| [`Series.copy`](series.copy.md) | Make a copy of this object’s indices and data. | - -### Indexing, iteration - -| | | -| ------------------------------------------------------- | ------------------------------------------------------------------ | -| ``[`Series.loc`](../dataframe/danfo.dataframe.loc.md)`` | Access a group of rows and columns by label(s) or a boolean array. | -| [`Series.iloc`](series.iloc.md) | Purely integer-location based indexing for selection by position. | - -### Binary operator functions - -| [`Series.add`](series.add.md) | Return Addition of series and other, element-wise (binary operator add). | -| --------------------------------- | --------------------------------------------------------------------------------------- | -| [`Series.sub`](series.sub.md) | Return Subtraction of series and other, element-wise (binary operator sub). | -| [`Series.mul`](series.mul.md) | Return Multiplication of series and other, element-wise (binary operator mul). | -| [`Series.div`](series.div.md) | Return Floating division of series and other, element-wise (binary operator truediv). | -| [`Series.mod`](series.mod.md) | Return Modulo of series and other, element-wise (binary operator mod). | -| [`Series.pow`](series.pow.md) | Return Exponential power of series and other, element-wise (binary operator pow). | -| [`Series.round`](series.round.md) | Round each value in a Series to the given number of decimals. | -| [`Series.lt`](series.lt.md) | Return Less than of series and other, element-wise (binary operator lt). | -| [`Series.gt`](series.gt.md) | Return Greater than of series and other, element-wise (binary operator gt). | -| [`Series.le`](series.le.md) | Return Less than or equal to of series and other, element-wise (binary operator le). | -| [`Series.ge`](series.ge.md) | Return Greater than or equal to of series and other, element-wise (binary operator ge). | -| [`Series.ne`](series.ne.md) | Return Not equal to of series and other, element-wise (binary operator ne). | -| [`Series.eq`](series.eq.md) | Return Equal to of series and other, element-wise (binary operator eq). | -| [`Series.dot`](broken-reference) | Compute the dot product between the Series and the columns of other. | - -### Function application & GroupBy - -| [`Series.apply`](series.apply.md) | Invoke function on values of Series. | -| --------------------------------- | ------------------------------------------------------- | -| [`Series.map`](series.map.md) | Map values of Series according to input correspondence. | - -### Computations / descriptive stats - -| [`Series.abs`](series.abs.md) | Return a Series with absolute numeric value of each element. | -| ----------------------------------------------------------- | ---------------------------------------------------------------- | -| [`Series.corr`](broken-reference) | Compute correlation with other Series, excluding missing values. | -| [`Series.count`](series.count.md) | Return number of non-NaN observations in the Series. | -| [`Series.cummax`](../dataframe/danfo.dataframe.cummax.md) | Return cumulative maximum over a DataFrame or Series axis. | -| [`Series.cummin`](../dataframe/danfo.dataframe.cummin.md) | Return cumulative minimum over a DataFrame or Series axis. | -| [`Series.cumprod`](../dataframe/danfo.dataframe.cumprod.md) | Return cumulative product over a DataFrame or Series axis. | -| [`Series.cumsum`](../dataframe/danfo.dataframe.cumsum.md) | Return cumulative sum over a DataFrame or Series axis. | -| [`Series.describe`](series.describe.md) | Generate descriptive statistics. | -| [`Series.max`](series.max.md) | Return the maximum of the values for the requested axis. | -| [`Series.mean`](series.mean.md) | Return the mean of the values for the requested axis. | -| [`Series.median`](series.median.md) | Return the median of the values for the requested axis. | -| [`Series.min`](series.min.md) | Return the minimum of the values for the requested axis. | -| [`Series.mode`](series.mode.md) | Return the mode(s) of the dataset. | -| [`Series.std`](series.std.md) | Return sample standard deviation over requested axis. | -| [`Series.sum`](series.sum.md) | Return the sum of the values for the requested axis. | -| [`Series.var`](series.var.md) | Return unbiased variance over requested axis. | -| [`Series.unique`](series.unique.md) | Return unique values of Series object. | -| [`Series.nunique`](series.nunique.md) | Return number of unique elements in the object. | -| [`Series.value_counts`](series.value\_counts.md) | Return a Series containing counts of unique values. | - -### Reindexing / selection / label manipulation - -| | | -| ------------------------------------------------------ | -------------------------------------------------------- | -| [`Series.drop_duplicates`](series.drop\_duplicates.md) | Return Series with duplicate values removed. | -| [`Series.head`](series.head.md) | Return the first n rows. | -| [`Series.reset_index`](series.reset\_index.md) | Generate a new DataFrame or Series with the index reset. | -| [`Series.sample`](series.sample.md) | Return a random sample of items from an axis of object. | -| [`Series.tail`](series.tail.md) | Return the last n rows. | - -### Missing data handling - -| | | -| ------------------------------------- | ------------------------------------------------ | -| [`Series.dropna`](series.dropna.md) | Return a new Series with missing values removed. | -| [`Series.fillna`](series.fillna.md) | Fill NaN values using the specified method. | -| [`Series.isna`](series.isna.md) | Detect missing values. | -| [`Series.replace`](series.replace.md) | Replace values given in to\_replace with value. | - -### Reshaping, sorting - -| [`Series.argsort`](series.argsort.md) | Return the integer indices that would sort the Series values. | -| ---------------------------------------------- | ------------------------------------------------------------- | -| [`Series.argmin`](series.argmin.md) | Return int position of the smallest value in the Series. | -| [`Series.argmax`](series.argmax.md) | Return int position of the largest value in the Series. | -| [`Series.sort_values`](series.sort\_values.md) | Sort by the values. | - -### Accessors - -Danfo provides dtype-specific methods under various accessors. These are separate namespaces within [`Series`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Series.html#pandas.Series) that only apply to specific data types. - -| Data Type | Accessor | -| --------- | -------- | -| Datetime | dt | -| String | str | - -#### Datetimelike properties - -`Series.dt` can be used to access the values of the series as datetime and return several properties. These can be accessed like `Series.dt.`. - -**Datetime methods** - -| | | -| -------------------------------------------------- | ------------------------------------------------------------------ | -| [`Series.dt.year`](series.dt.year.md) | The year of the datetime. | -| [`Series.dt.month`](series.dt.month.md) | The month as January=1, December=12. | -| [`Series.dt.day`](series.dt.day.md) | The day of the datetime. | -| [`Series.dt.hour`](series.dt.hour.md) | The hours of the datetime. | -| [`Series.dt.minute`](series.dt.minute.md) | The minutes of the datetime. | -| [`Series.dt.second`](series.dt.second.md) | The seconds of the datetime. | -| [`Series.dt.weekdays`](series.dt.weekdays.md) | The day of the week with Monday=0, Sunday=6. | -| [`Series.dt.month_name`](series.dt.month\_name.md) | Return the month names of the DateTimeIndex with specified locale. | - -#### String handling - -`Series.str` can be used to access the values of the series as strings and apply several methods to it. These can be accessed like `Series.str.`. - -| [`Series.str.capitalize`](series.str.capitalize.md) | Capitalize the first character of each string | -| ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | -| [`Series.str.toUpperCase`](series.str.touppercase.md) | Converts all characters to uppercase. | -| [`Series.str.toLowerCase`](series.str.tolowercase.md) | Converts all characters to lowercase. | -| [`Series.str.charAt`](series.str.charat.md) | Returns the character at the specified index (position). | -| [`Series.str.concat`](series.str.concat.md) | Joins two or more strings/arrays. | -| [`Series.str.startsWith`](series.str.startswith.md) | Checks whether a string begins with specified characters. | -| [`Series.str.endsWith`](series.str.endswith.md) | Checks whether a string ends with specified characters | -| [`Series.str.includes`](series.str.includes.md) | Checks whether a string contains the specified string/characters. | -| [`Series.str.indexOf`](series.str.indexof.md) | Returns the position of the first found occurrence of a specified value in a string. | -| [`Series.str.lastIndexOf`](series.str.lastindexof.md) | Returns the position of the last found occurrence of a specified value in a string. | -| [`Series.str.repeat`](series.str.repeat.md) | Returns a new string with a specified number of copies of an existing string. | -| [`Series.str.search`](series.str.search.md) | Searches a string for a specified value, or regular expression, and returns the position of the match. | -| [`Series.str.slice`](series.str.slice.md) | Extracts a part of a string and returns a new string. | -| [`Series.str.split`](series.str.split.md) | Splits a string into an array of substrings. | -| [`Series.str.substr`](series.str.substr.md) | Extracts the characters from a string, beginning at a specified start position, and through the specified number of character. | -| [`Series.str.substring`](series.str.substring.md) | Extracts the characters from a string, between two specified indices. | -| [`Series.str.len`](series.str.len.md) | Counts the number of characters in each string. | -| [`Series.str.trim`](series.str.trim.md) | Removes whitespace from both ends of a string. | -| [`Series.str.join`](series.str.join.md) | Joins strings to specified value. | -| [`Series.str.replace`](series.str.replace.md) | Replace each occurrence of pattern/regex in the Series/Index. | - -### Plotting - -`Series.plot` is both a callable method and a namespace attribute for specific plotting methods of the form `Series.plot.`. - -| | | -| ----------------------------------------------------- | ------------------------------------------------------------- | -| [`Series.plot.bar`](../plotting/bar-charts.md) | Vertical bar plot. | -| [`Series.plot.box`](../plotting/box-plots.md) | Make a box plot of the DataFrame columns. | -| [`Series.plot.violin`](../plotting/box-plots.md) | Make a violin plot of the DataFrame columns. | -| [`Series.plot.hist`](../plotting/histograms.md) | Draw one histogram of the DataFrame’s columns. | -| [`Series.plot.scatter`](../plotting/scatter-plots.md) | Generate Kernel Density Estimate plot using Gaussian kernels. | -| [`Series.plot.line`](../plotting/line-charts.md) | Plot Series or DataFrame as lines. | -| [`Series.plot.pie`](../plotting/pie-charts.md) | Generate a pie plot. | -| [`Timeseries Plots`](../plotting/timeseries-plots.md) | Time series plots | -| [`Table`](../plotting/tables.md) | Display Series as Interactive table in Div | - -### Serialization / IO / conversion - -| | | -| ------------------------------------------------------ | ---------------------------------------------------- | -| [`Series.to_csv`](../dataframe/dataframe.to\_csv.md) | Write object to a comma-separated values (csv) file. | -| [`Series.to_json`](../dataframe/dataframe.to\_json.md) | Convert the object to a JSON string. | diff --git a/api-reference-v1-stable/series/creating-a-series.md b/api-reference-v1-stable/series/creating-a-series.md deleted file mode 100644 index 3c8e4ba..0000000 --- a/api-reference-v1-stable/series/creating-a-series.md +++ /dev/null @@ -1,210 +0,0 @@ -# Creating a Series - -new danfo.**Series**\(data, options\) - - - - - - - - - - - - - - - - - - - - - -
ParametersTypeDescription
data1D Array, 1D Tensor, JSON object.Flat data structure to load into DataFrame
optionsObject -

Optional configuration object. Supported properties are: -
-

-

index: Array of numeric or string names for subseting array. If - not specified, indexes are auto-generated. -
-

-

dtypes: Array of data types for each the column. If not specified, - dtypes are/is inferred. -
-

-

config: General configuration object for extending or setting NDframe - behavior. See full options here

-
- -In order to create a Series, you need to call the new Keyword and pass a flat data structure. In the following examples, we show you how to create a Series by specifying different config options. - -### Creating a Series from an object: - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -obj_data = { 'B': ["bval1", "bval2", "bval3", "bval4"] } -df = new dfd.Series(obj_data) -df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -```markup - - - - - - - - Document - - - - - - - - -``` -{% endtab %} -{% endtabs %} - -```javascript -╔═══╤═══════╗ -║ 0 │ bval1 ║ -╟───┼───────╢ -║ 1 │ bval2 ║ -╟───┼───────╢ -║ 2 │ bval3 ║ -╟───┼───────╢ -║ 3 │ bval4 ║ -╚═══╧═══════╝ -``` - -### Creating a Series from an array - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -obj_data = ["bval1", "bval2", "bval3", "bval4"] -df = new dfd.Series(obj_data) -df.print() -``` -{% endtab %} - -{% tab title="Browser" %} -```markup - - - - - - - - Document - - - - - - - - -``` -{% endtab %} -{% endtabs %} - -```text -╔═══╤═══════╗ -║ 0 │ bval1 ║ -╟───┼───────╢ -║ 1 │ bval2 ║ -╟───┼───────╢ -║ 2 │ bval3 ║ -╟───┼───────╢ -║ 3 │ bval4 ║ -╚═══╧═══════╝ -``` - -### Creating a Series and specifying index and dtypes - -You can create a Series and specify options like index, dtypes, as well as configuration options for display, and memory mode etc. - -> Note: Specifing dtypes, and index on Series creation makes the process slightly faster. - -{% tabs %} -{% tab title="Node" %} -```javascript -import { Series } from "danfojs" - -let data1 = [1, 2, 3, 4, 5]; -let index = ["a", "b", "c", "d", "e"]; -let dtypes = ["int32",] - -let df = new Series(data1, { index, dtypes }); -df.print() -``` -{% endtab %} -{% endtabs %} - -```text -╔═══╤═══╗ -║ a │ 1 ║ -╟───┼───╢ -║ b │ 2 ║ -╟───┼───╢ -║ c │ 3 ║ -╟───┼───╢ -║ d │ 4 ║ -╟───┼───╢ -║ e │ 5 ║ -╚═══╧═══╝ -``` - -### Creating a Series and specifying memory mode - -To use less space on Series creation, you can set the low memory mode as demonstrated below: - -```javascript -import { Series } from "danfojs" - -let data1 = [1, 2.3, 3, 4, 5, "girl"]; - -let df = new Series(data1, { - config: { lowMemoryMode: true } -}); -df.print() -``` - -{% hint style="info" %} -**Note**: In low memory mode, less space is used by the Series. -{% endhint %} - diff --git a/api-reference-v1-stable/series/danfo.series.add.md b/api-reference-v1-stable/series/danfo.series.add.md deleted file mode 100644 index 7cd6150..0000000 --- a/api-reference-v1-stable/series/danfo.series.add.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -description: 'Return Addition of series and other, element-wise (binary operator add).' ---- - -# danfo.Series.add - -Return Addition of series and other, element-wise \(binary operator add\). - - **parameter:** {other} Series or Number to add - - **return:** Series - -**Example** - -```javascript -let data = [1, 2, 3, 4, 5, 6] -let data2 = [30, 40, 39, 1, 2, 1] -let sf = new Series(data) -let sf2 = new Series(data2) -sf.add(sf2) -``` - diff --git a/api-reference-v1-stable/series/danfo.series.apply.md b/api-reference-v1-stable/series/danfo.series.apply.md deleted file mode 100644 index d59a99c..0000000 --- a/api-reference-v1-stable/series/danfo.series.apply.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -description: invoke a function on Series Value ---- - -# danfo.Series.apply - -> danfo.series.**apply**\(callable\) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L718)\] - -| Parameters | Type | Description | Default | -| :--- | :--- | :--- | :--- | -| callable | Function | Function \(can be anonymous\) to apply | | - -**Returns:** - - ****return **Series** - -\*\*\*\* - -**Example** - -```javascript -const dfd = require("danfojs") - -let sf = new dfd.Series([1, 2, 3, 4, 5, 6, 7, 8]) - -let apply_func = (x) => { - return x + x -} -sf.apply(apply_func).print() -``` - -**OUTPUT:** - -![](../../.gitbook/assets/series_apply.png) - -```javascript -const dfd = require("danfojs") - -let sf = new dfd.Series([1, 2, 3, 4, 5, 6, 7, 8]) - -sf.apply(Math.log).print() -``` - -**OUTPUT:** - -![](../../.gitbook/assets/series_apply1.png) - -```javascript -const dfd = require("danfojs") - -let sf = new dfd.Series(["Rice","Beans","Yam","Banana","Wheat"]) - -sf.apply((x)=>{ - return x.toLocaleLowerCase() -}).print() -``` - -**OUTPUT** - -![](../../.gitbook/assets/series_apply2.png) - - - diff --git a/api-reference-v1-stable/series/danfo.series.copy.md b/api-reference-v1-stable/series/danfo.series.copy.md deleted file mode 100644 index c610c04..0000000 --- a/api-reference-v1-stable/series/danfo.series.copy.md +++ /dev/null @@ -1,22 +0,0 @@ -# danfo.Series.copy - -Make a new copy of Series - - - -**parameter:** - - **return:** {Series} - -**Example** - -```javascript -let sf = new Series([30.21091, 40.190901, 3.564, 5.0212]) -sf_copy = sf.copy() - - -let sf = new Series([30.21091, 40.190901, 3.564, 5.0212]) -sf = sf.set_index({ "index": ["a", "b", "c", "d"] }) -sf_copy = sf.copy() -``` - diff --git a/api-reference-v1-stable/series/danfo.series.count.md b/api-reference-v1-stable/series/danfo.series.count.md deleted file mode 100644 index 50a5789..0000000 --- a/api-reference-v1-stable/series/danfo.series.count.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -description: Return the sum of the values in a series. ---- - -# danfo.Series.count - -Return number of non-NA/null observations in the Series. - -This is equivalent to the method numpy.sum - - **parameter:** - - **return:** {Number}, sum of values in Series - -**Example** - -```javascript -let data = ["boy", "gitl", "woman", NaN] -let sf = new Series(data) -sf.count() -``` - - - diff --git a/api-reference-v1-stable/series/danfo.series.describe.md b/api-reference-v1-stable/series/danfo.series.describe.md deleted file mode 100644 index 184dbe9..0000000 --- a/api-reference-v1-stable/series/danfo.series.describe.md +++ /dev/null @@ -1,26 +0,0 @@ -# danfo.Series.describe - - - -Generate descriptive statistics. Descriptive statistics include those that summarize the central tendency, dispersion and shape of a dataset’s distribution, excluding NaN values - - - -**parameter:** - - **return:** {frame} - -**Example** - -```javascript -let data = [{ alpha: "A", count: 1 }, { alpha: "B", count: 2 }, { alpha: "C", count: 3 }] -let df = new Series(data) -df.set_index({ "index": ["one", "two", "three"] }) - - -let data = [1,2,3,4,5,6] -let df = new Series(data) -df.set_index({ "index": ["one", "two", "three", "four", "five", "six"], "inplace": true }) -df.reset_index() -``` - diff --git a/api-reference-v1-stable/series/danfo.series.div.md b/api-reference-v1-stable/series/danfo.series.div.md deleted file mode 100644 index ae2731b..0000000 --- a/api-reference-v1-stable/series/danfo.series.div.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -description: >- - Return Floating division of series and other, element-wise (binary operator - truediv). ---- - -# danfo.Series.div - -Return division of series and other, element-wise \(binary operator div\). - -Equivalent to series / other - - **parameter:** {other} Series, Number to divide with. - - **return:** Series - -**Example** - -```javascript -let data1 = [30, 40, 3, 5] -let data2 = [1, 2, 3, 4] -let sf1 = new Series(data1) -let sf2 = new Series(data2) -sf1.div(sf2) -``` - diff --git a/api-reference-v1-stable/series/danfo.series.head.md b/api-reference-v1-stable/series/danfo.series.head.md deleted file mode 100644 index 1bc9d5e..0000000 --- a/api-reference-v1-stable/series/danfo.series.head.md +++ /dev/null @@ -1,25 +0,0 @@ ---- -description: This function returns the first n rows for the object based on position. ---- - -# danfo.Series.head - - - -Prints the first n values in a Series - - **parameter:** {rows} Number of rows to return - - **return:** Series - -**Example** - -```javascript -let data = [1, 2, 3, 4, 5, 620, 30, 40, 39, 89, 78] -let cols = ["A"] -let sf = new Series(data, { columns: cols }) -sf.head() -``` - - - diff --git a/api-reference-v1-stable/series/danfo.series.map.md b/api-reference-v1-stable/series/danfo.series.map.md deleted file mode 100644 index 9d7cad4..0000000 --- a/api-reference-v1-stable/series/danfo.series.map.md +++ /dev/null @@ -1,42 +0,0 @@ ---- -description: Map the value of a series to it representation ---- - -# danfo.Series.map - -> danfo.series.**map**\(callable\) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L685)\] - -| Parameter | Type | Description | Default | -| :--- | :--- | :--- | :--- | -| callable | Function or Object | callable can either be a function or an object\({}\) | | - -**Example** - -```javascript -const dfd = require("danfojs") - -let sf = new dfd.Series([1,2,3,4]) -let map = { 1: "ok", 2: "okie", 3: "frit", 4: "gop" } -sf.map(map) - -``` - -**OUTPUT** - -![](../../.gitbook/assets/series_map.png) - -```javascript -const dfd = require("danfojs") - -let sf = new dfd.Series([1,2,3,4]) - -sf.map((x)=>{ - return `I have ${x} cat(s)` -}).print() - -``` - -**OUTPUT** - -![](../../.gitbook/assets/series_map1.png) - diff --git a/api-reference-v1-stable/series/danfo.series.max.md b/api-reference-v1-stable/series/danfo.series.max.md deleted file mode 100644 index cac4ba1..0000000 --- a/api-reference-v1-stable/series/danfo.series.max.md +++ /dev/null @@ -1,2 +0,0 @@ -# danfo.Series.max - diff --git a/api-reference-v1-stable/series/danfo.series.maximum.md b/api-reference-v1-stable/series/danfo.series.maximum.md deleted file mode 100644 index 9082120..0000000 --- a/api-reference-v1-stable/series/danfo.series.maximum.md +++ /dev/null @@ -1,22 +0,0 @@ -# danfo.Series.maximum - -Return maximum of series and other, element-wise \(binary operator div\). - - - - **parameter:** {other} Series, Numbers to check maximum against - - **return:** {Series} - -**Example** - -```javascript -let data1 = [30, 40, 3, 5] -let data2 = [10, 41, 2] -let sf1 = new Series(data1) -let sf2 = new Series(data2) -sf1.maximum(sf2) -``` - - - diff --git a/api-reference-v1-stable/series/danfo.series.mean.md b/api-reference-v1-stable/series/danfo.series.mean.md deleted file mode 100644 index 6ace487..0000000 --- a/api-reference-v1-stable/series/danfo.series.mean.md +++ /dev/null @@ -1,2 +0,0 @@ -# danfo.Series.mean - diff --git a/api-reference-v1-stable/series/danfo.series.median.md b/api-reference-v1-stable/series/danfo.series.median.md deleted file mode 100644 index 077c0ec..0000000 --- a/api-reference-v1-stable/series/danfo.series.median.md +++ /dev/null @@ -1,2 +0,0 @@ -# danfo.Series.median - diff --git a/api-reference-v1-stable/series/danfo.series.min.md b/api-reference-v1-stable/series/danfo.series.min.md deleted file mode 100644 index 22f3589..0000000 --- a/api-reference-v1-stable/series/danfo.series.min.md +++ /dev/null @@ -1,2 +0,0 @@ -# danfo.Series.min - diff --git a/api-reference-v1-stable/series/danfo.series.minimum.md b/api-reference-v1-stable/series/danfo.series.minimum.md deleted file mode 100644 index 2a9d9c6..0000000 --- a/api-reference-v1-stable/series/danfo.series.minimum.md +++ /dev/null @@ -1,22 +0,0 @@ -# danfo.Series.minimum - - - -Return minimum of series and other, element-wise \(binary operator div\). - - - - **parameter:** {other} Series, Numbers to check minimum against - - **return:** {Series} - -**Example** - -```javascript -let data1 = [30, 40, 3, 5] -let data2 = [10, 41, 2] -let sf1 = new Series(data1) -let sf2 = new Series(data2) -sf1.minimum(sf2) -``` - diff --git a/api-reference-v1-stable/series/danfo.series.mod.md b/api-reference-v1-stable/series/danfo.series.mod.md deleted file mode 100644 index 577014d..0000000 --- a/api-reference-v1-stable/series/danfo.series.mod.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -description: 'Return Modulo of series and other, element-wise (binary operator mod).' ---- - -# danfo.Series.mod - -Return Modulo of series and other, element-wise \(binary operator mod\). - -Equivalent to series % other - - **parameter:** {other} Series, Number - - **return:** Series - -**Example** - -```javascript -let data1 = [2, 30, 4, 5] -let data2 = [1.1, 2.2, 3.3, 2.4] -let sf1 = new Series(data1) -let sf2 = new Series(data2) -sf1.mod(sf2) -``` - diff --git a/api-reference-v1-stable/series/danfo.series.mode.md b/api-reference-v1-stable/series/danfo.series.mode.md deleted file mode 100644 index 8d86e6e..0000000 --- a/api-reference-v1-stable/series/danfo.series.mode.md +++ /dev/null @@ -1,2 +0,0 @@ -# danfo.Series.mode - diff --git a/api-reference-v1-stable/series/danfo.series.mul.md b/api-reference-v1-stable/series/danfo.series.mul.md deleted file mode 100644 index 6cdac92..0000000 --- a/api-reference-v1-stable/series/danfo.series.mul.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -description: 'Return Multiplication of series and other, element-wise (binary operator mul).' ---- - -# danfo.Series.mul - -Return Multiplication of series and other, element-wise \(binary operator mul\). - -Equivalent to series \* other, but with support to substitute a fill\_value for missing data in one of the inputs. - - **parameter:** {Series, Number to multiply with. - - **return:** Series - -**Example** - -```javascript -let data1 = [30, 40, 3, 5] -let data2 = [1, 2, 3, 4] -let sf1 = new Series(data1) -let sf2 = new Series(data2) -sf1.mul(sf2) -``` - - - diff --git a/api-reference-v1-stable/series/danfo.series.pow.md b/api-reference-v1-stable/series/danfo.series.pow.md deleted file mode 100644 index 291a993..0000000 --- a/api-reference-v1-stable/series/danfo.series.pow.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -description: >- - Return Exponential power of series and other, element-wise (binary operator - pow). ---- - -# danfo.Series.pow - -Return Exponential power of series and other, element-wise \(binary operator pow\). - -Equivalent to series \*\* other - - **parameter:** {other} Series, Number to multiply with. - - **return:** Series - -**Example** - -```javascript -let data1 = [2, 3, 4, 5] -let data2 = [1, 2, 3, 0] -let sf1 = new Series(data1) -let sf2 = new Series(data2) -sf1.pow(sf2) -``` - diff --git a/api-reference-v1-stable/series/danfo.series.reset_index.md b/api-reference-v1-stable/series/danfo.series.reset_index.md deleted file mode 100644 index 7a908a9..0000000 --- a/api-reference-v1-stable/series/danfo.series.reset_index.md +++ /dev/null @@ -1,31 +0,0 @@ -# danfo.Series.reset\_index - - - -Generate a new Series with the index reset. This is useful when the index needs to be treated as a column, or when the index is meaningless and needs to be reset to the default before another operation. - - - -**parameter:** {kwargs} {inplace: Modify the Series in place \(do not create a new object, drop: Just reset the index, without inserting it as a column in the new DataFrame.} - - **return:** {Series} - -**Example** - -```javascript -const dfd = require("danfojs") - -let data = [{ alpha: "A", count: 1 }, { alpha: "B", count: 2 }, { alpha: "C", count: 3 }] -let df = new dfd.Series(data) -let df_new = df.set_index({ "index": ["one", "two", "three"] }) -let df_reset = df_new.reset_index() -df_reset.print() - - -let data = [1,2,3,4,5,6] -let df = new Series(data) -df.set_index({ "index": ["one", "two", "three", "four", "five", "six"], "inplace": true }) -let df_new = df.reset_index() -df_new -``` - diff --git a/api-reference-v1-stable/series/danfo.series.round.md b/api-reference-v1-stable/series/danfo.series.round.md deleted file mode 100644 index 2bbacbb..0000000 --- a/api-reference-v1-stable/series/danfo.series.round.md +++ /dev/null @@ -1,20 +0,0 @@ -# danfo.Series.round - -Round each value in a Series to the given number of decimals. - - - - **parameter:** {dp} Number, Numbers of Decimal places to round to - - **return:** {Series} - -**Example** - -```javascript -let data1 = [30.21091, 40.190901, 3.564, 5.0212] -let sf = new Series(data1) -sf.round(1) -``` - - - diff --git a/api-reference-v1-stable/series/danfo.series.sample.md b/api-reference-v1-stable/series/danfo.series.sample.md deleted file mode 100644 index fa8f326..0000000 --- a/api-reference-v1-stable/series/danfo.series.sample.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -description: Return a random sample of items from an axis of object. ---- - -# danfo.Series.sample - -Gets \[num\] number of random rows in a Series - - **parameter:** {rows} Number of rows to return - - **return:** Series - -**Example** - -```javascript -let data = [1, 2, 3, 4, 5, 620, 30, 40, 39, 89, 78] -let sf = new Series(data) -sf.sample(2) -``` - - - diff --git a/api-reference-v1-stable/series/danfo.series.set_index.md b/api-reference-v1-stable/series/danfo.series.set_index.md deleted file mode 100644 index 5cb3d28..0000000 --- a/api-reference-v1-stable/series/danfo.series.set_index.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -description: Assign new Index to Series ---- - -# danfo.Series.set\_index - -> danfo.series.**set\_index\(**kwargs**\)** \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L614)\] - -| Parameters | Type | Description | Default | -| :--- | :--- | :--- | :--- | -| kwargs | Object {} | The object contains the key **index** and assigned an array value of equal length to the Series. format {"index": \[Array\] } | | - -**Example** - -```javascript -const dfd = require("danfojs") - -let data = [{ alpha: "A", count: 1 }, { alpha: "B", count: 2 }, { alpha: "C", count: 3 }] -let df = new dfd.Series(data) -let df_new = df.set_index({ "index": ["one", "two", "three"] }) -df_new.print() -``` - -**OUTPUT** - -![](../../.gitbook/assets/series.reset_index.png) - -```javascript -const dfd = require("danfojs") - -let data = ["Humans","Life","Meaning","Fact","Truth"] -let df = new dfd.Series(data) -let df_new = df.set_index({ "index": ["H", "L", "M","F","T"] }) -df_new.print() -``` - -**OUTPUT** - -![](../../.gitbook/assets/series_reset_index2.png) - diff --git a/api-reference-v1-stable/series/danfo.series.sort_values.md b/api-reference-v1-stable/series/danfo.series.sort_values.md deleted file mode 100644 index 0a0c4e7..0000000 --- a/api-reference-v1-stable/series/danfo.series.sort_values.md +++ /dev/null @@ -1,27 +0,0 @@ -# danfo.Series.sort\_values - - - -Sort a Series in ascending or descending order by some criterion. - - - - **parameter:** {kwargs} Object, {ascending \(Bool\): Whether to return sorted values in ascending order or not, inplace \(Bool\): Whether to perform sorting on the original Series or not} - - **return:** {Number} - -**Example** - -```javascript -let sf = new Series([20, 30, 1, 2, 4, 57, 89, 0, 4]) -sf.sort_values() - - -let sf = new Series([20, 30, 1, 2, 4, 57, 89, 0, 4]) -sf.sort_values({ "inplace": true }) - - -let sf = new Series([20, 30, 1, 2, 4, 57, 89, 0, 4]) -sf.sort_values({ "ascending": false, "inplace": true }) -``` - diff --git a/api-reference-v1-stable/series/danfo.series.std.md b/api-reference-v1-stable/series/danfo.series.std.md deleted file mode 100644 index 8f48ef2..0000000 --- a/api-reference-v1-stable/series/danfo.series.std.md +++ /dev/null @@ -1,20 +0,0 @@ -# danfo.Series.std - -Return sample standard deviation over requested axis. - - - - **parameter:** - - **return:** {Number} - -**Example** - -```javascript -let data1 = [30, 40, 3, 5] -let sf = new Series(data1) -sf.std() -``` - - - diff --git a/api-reference-v1-stable/series/danfo.series.sub.md b/api-reference-v1-stable/series/danfo.series.sub.md deleted file mode 100644 index 8867c14..0000000 --- a/api-reference-v1-stable/series/danfo.series.sub.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -description: 'Return Subtraction of series and other, element-wise (binary operator sub).' ---- - -# danfo.Series.sub - -Returns the subtraction between a series and other, element-wise \(binary operator subtraction\). - -Equivalent to series - other - - **parameter:** {other} Series, Number to subtract - - **return:** Series - -**Example** - -```javascript -let data1 = [30, 40, 39, 1, 2, 1] -let data2 = [1, 2, 3, 4, 5, 6] -let sf1 = new Series(data1) -let sf2 = new Series(data2) -sf1.sub(sf2) -``` - diff --git a/api-reference-v1-stable/series/danfo.series.sum-1.md b/api-reference-v1-stable/series/danfo.series.sum-1.md deleted file mode 100644 index 6ec14cb..0000000 --- a/api-reference-v1-stable/series/danfo.series.sum-1.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -description: Return the sum of the values in a series. ---- - -# danfo.Series.sum - -Return the sum of the values for the requested axis. - -This is equivalent to the method numpy.sum. - - **parameter:** - - **return:** Series - -**Example** - -```javascript -let data1 = [30, 40, 3, 5] -let sf = new Series(data1) -sf.sum() -``` - diff --git a/api-reference-v1-stable/series/danfo.series.tail.md b/api-reference-v1-stable/series/danfo.series.tail.md deleted file mode 100644 index e83307d..0000000 --- a/api-reference-v1-stable/series/danfo.series.tail.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -description: Prints the last n values in a Series ---- - -# danfo.Series.tail - -Prints the first n values in a Series - - **parameter:** {rows} Number of rows to return - - **return:** Series - -**Example** - -```javascript -let data = [1, 2, 3, 4, 5, 620, 30, 40, 39, 89, 78] -let sf = new Series(data) -sf.tail() -``` - - - diff --git a/api-reference-v1-stable/series/danfo.series.tostring.md b/api-reference-v1-stable/series/danfo.series.tostring.md deleted file mode 100644 index 5807850..0000000 --- a/api-reference-v1-stable/series/danfo.series.tostring.md +++ /dev/null @@ -1,18 +0,0 @@ -# danfo.Series.toString - - - -Prints the data in a Series as a grid of row and columns - - - -**parameter:** - - **return:** {frame} - -**Example** - -```javascript - -``` - diff --git a/api-reference-v1-stable/series/danfo.series.var.md b/api-reference-v1-stable/series/danfo.series.var.md deleted file mode 100644 index 822edc7..0000000 --- a/api-reference-v1-stable/series/danfo.series.var.md +++ /dev/null @@ -1,20 +0,0 @@ -# danfo.Series.var - - - -Return unbiased variance of Series. - - - - **parameter:** - - **return:** {Number} - -**Example** - -```javascript -let data1 = [30, 40, 3, 5] -let sf = new Series(data1) -sf.var() -``` - diff --git a/api-reference-v1-stable/series/series.abs.md b/api-reference-v1-stable/series/series.abs.md deleted file mode 100644 index 843dd5e..0000000 --- a/api-reference-v1-stable/series/series.abs.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -description: Returns the absolute value in a Series ---- - -# Series.abs - -> danfo.Series.**abs**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L793)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ---------------------------------------------------------------------------------------------------- | ------------------------------------- | -| options | Object | **inplace**: Boolean indicating whether to perform the operation in-place or not. Defaults to false |

{

inplace: false

}

| - -**Returns:** Series - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [-10, 45, 56, -25, 23, -20, 10] -let sf = new dfd.Series(data1) - -sf.abs().print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 10 ║ -╟───┼──────────────────────╢ -║ 1 │ 45 ║ -╟───┼──────────────────────╢ -║ 2 │ 56 ║ -╟───┼──────────────────────╢ -║ 3 │ 25 ║ -╟───┼──────────────────────╢ -║ 4 │ 23 ║ -╟───┼──────────────────────╢ -║ 5 │ 20 ║ -╟───┼──────────────────────╢ -║ 6 │ 10 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.add.md b/api-reference-v1-stable/series/series.add.md deleted file mode 100644 index e55b1b8..0000000 --- a/api-reference-v1-stable/series/series.add.md +++ /dev/null @@ -1,86 +0,0 @@ ---- -description: Return Addition of series and other, element-wise (binary operator add). ---- - -# Series.add - -> danfo.Series.add(other, options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L129)] - -| Parameters | Type | Description | Default | -| ---------- | ------------- | ---------------------------------------------------------------------------------------------- | ------------------------------------- | -| other | Series\|int\| | values | | -| options | Object | inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false |

{

inplace: false

}

| - -**Return:** Series - -**Example** - -subtract from values of another series - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [30, 40, 3, 5] -let data2 = [1, 2, 3, 4] -let sf1 = new dfd.Series(data1) -let sf2 = new dfd.Series(data2) -sf1.add(sf2).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 31 ║ -╟───┼──────────────────────╢ -║ 1 │ 42 ║ -╟───┼──────────────────────╢ -║ 2 │ 6 ║ -╟───┼──────────────────────╢ -║ 3 │ 9 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -subtract from a value - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [1, 2, 3, 4, 5] -let sf1 = new dfd.Series(data1) - -sf1.add(2).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 3 ║ -╟───┼──────────────────────╢ -║ 1 │ 4 ║ -╟───┼──────────────────────╢ -║ 2 │ 5 ║ -╟───┼──────────────────────╢ -║ 3 │ 6 ║ -╟───┼──────────────────────╢ -║ 4 │ 7 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/series/series.and.md b/api-reference-v1-stable/series/series.and.md deleted file mode 100644 index 85c22cb..0000000 --- a/api-reference-v1-stable/series/series.and.md +++ /dev/null @@ -1,132 +0,0 @@ ---- -description: >- - Returns the logical AND between Series and other. Supports element wise - operations and broadcasting. ---- - -# Series.and - -> danfo.Series.and\(other\) \[[source](https://github.com/opensource9ja/danfojs/blob/e25010c26d9c423412613d820015a48ad03d5c6d/danfojs-node/src/core/series.js#L1243)\] - -| Parameters | Type | Description | Default | -| :--- | :--- | :--- | :--- | -| other | Series, Scalar, Array of Scalars | Data to compare with | | - - **Return:** Series - -### **Logical AND between two Series object** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [false, false, false, true, false, false, true]; -let data2 = [false, false, false, false, false, false, true]; - -let sf = new dfd.Series(data1); -let sf2 = new dfd.Series(data2); -let res = sf.and(sf2) -res.print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```text -╔═══╤═══════╗ -║ 0 │ false ║ -╟───┼───────╢ -║ 1 │ false ║ -╟───┼───────╢ -║ 2 │ false ║ -╟───┼───────╢ -║ 3 │ false ║ -╟───┼───────╢ -║ 4 │ false ║ -╟───┼───────╢ -║ 5 │ false ║ -╟───┼───────╢ -║ 6 │ true ║ -╚═══╧═══════╝ -``` -{% endtab %} -{% endtabs %} - -### **Logical AND between Series and Array of the same length** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [false, false, false, true, false, false, true]; -let data2 = [false, false, false, false, false, false, true]; - -let sf = new dfd.Series(data1); -let res = sf.and(data2) -res.print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```text -╔═══╤═══════╗ -║ 0 │ false ║ -╟───┼───────╢ -║ 1 │ false ║ -╟───┼───────╢ -║ 2 │ false ║ -╟───┼───────╢ -║ 3 │ false ║ -╟───┼───────╢ -║ 4 │ false ║ -╟───┼───────╢ -║ 5 │ false ║ -╟───┼───────╢ -║ 6 │ true ║ -╚═══╧═══════╝ -``` -{% endtab %} -{% endtabs %} - -### **Logical AND between a Series and single value with broadcasting** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") -let data1 = [false, false, false, true, false, false, true]; - -let sf = new dfd.Series(data1); -let res = sf.and(false) -res.print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```text -╔═══╤═══════╗ -║ 0 │ false ║ -╟───┼───────╢ -║ 1 │ false ║ -╟───┼───────╢ -║ 2 │ false ║ -╟───┼───────╢ -║ 3 │ false ║ -╟───┼───────╢ -║ 4 │ false ║ -╟───┼───────╢ -║ 5 │ false ║ -╟───┼───────╢ -║ 6 │ false ║ -╚═══╧═══════╝ -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/series/series.append.md b/api-reference-v1-stable/series/series.append.md deleted file mode 100644 index 53e8f03..0000000 --- a/api-reference-v1-stable/series/series.append.md +++ /dev/null @@ -1,135 +0,0 @@ ---- -description: Add a new value or values to the end of a Series. ---- - -# Series.append - -danfo.Series.**append**(newValue, index, options) \[[source](https://github.com/opensource9ja/danfojs/blob/e25010c26d9c423412613d820015a48ad03d5c6d/danfojs-node/src/core/series.js#L1120)] - -| Parameters | Type | Description | Default | -| ---------- | ------------- | -------------------------------------------------------------------------------------------------------------------------- | ------- | -| newValue | Array, Series | Object to append | | -| index | Array | The new index value(s) to append to the Series. Must contain the same number of values as `newValues` as they map `1 - 1`. | | -| options | Object |

{
inplace: Whether to perform operation in-place or not.

}

| false | - -**Returns:** - - **** return **Series** - -**** - -### **Append new Series to the end of a Series** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let sf1 = new dfd.Series([1, 2, 3, 4], { index: ['f1', 'f2', 'f3', 'f4'] }) -let sf2 = new dfd.Series(["a", "b", "c"]) - -new_sf = sf1.append(sf2, ["f5", "f6", "f7"]) -new_sf.print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════╤═══╗ -║ f1 │ 1 ║ -╟────┼───╢ -║ f2 │ 2 ║ -╟────┼───╢ -║ f3 │ 3 ║ -╟────┼───╢ -║ f4 │ 4 ║ -╟────┼───╢ -║ f5 │ a ║ -╟────┼───╢ -║ f6 │ b ║ -╟────┼───╢ -║ f7 │ c ║ -╚════╧═══╝ -``` -{% endtab %} -{% endtabs %} - -### **Append new Series to the end of a Series in-place** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let sf1 = new dfd.Series([1, 2, 3, 4], { index: ['f1', 'f2', 'f3', 'f4'] }) -let sf2 = new dfd.Series(["a", "b", "c"]) -let newIndex = ["f5", "f6", "f7"] - -sf1.append(sf2, newIndex, { inplace: true }) -sf1.print() -``` -{% endtab %} -{% endtabs %} - -``` -╔════╤═══╗ -║ f1 │ 1 ║ -╟────┼───╢ -║ f2 │ 2 ║ -╟────┼───╢ -║ f3 │ 3 ║ -╟────┼───╢ -║ f4 │ 4 ║ -╟────┼───╢ -║ f5 │ a ║ -╟────┼───╢ -║ f6 │ b ║ -╟────┼───╢ -║ f7 │ c ║ -╚════╧═══╝ -``` - -### **Append an array to the end of Series** - -{% tabs %} -{% tab title="Node" %} -```javascript -let sf1 = new dfd.Series([1, 2, 3, 4], { index: ['f1', 'f2', 'f3', 'f4'] }) -let sfArr = ["a", "b", "c"] - -new_sf = sf1.append(sfArr, ["f5", "f6", "f7"]) -new_sf.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════╤═══╗ -║ f1 │ 1 ║ -╟────┼───╢ -║ f2 │ 2 ║ -╟────┼───╢ -║ f3 │ 3 ║ -╟────┼───╢ -║ f4 │ 4 ║ -╟────┼───╢ -║ f5 │ a ║ -╟────┼───╢ -║ f6 │ b ║ -╟────┼───╢ -║ f7 │ c ║ -╚════╧═══╝ - -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.apply.md b/api-reference-v1-stable/series/series.apply.md deleted file mode 100644 index 7f7050e..0000000 --- a/api-reference-v1-stable/series/series.apply.md +++ /dev/null @@ -1,149 +0,0 @@ ---- -description: Invoke a function on each value in a Series. ---- - -# Series.apply - -> danfo.series.**apply**(callable, options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L718)] - -| Parameters | Type | Description | Default | -| ---------- | -------- | ---------------------------------------------------------------------------------------------- | ------------------------------------- | -| callable | Function | Function (can be anonymous) to apply | | -| options | Object | inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false |

{

inplace: false

}

| - -**Returns:** - - **** return **Series** - -**** - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let sf = new dfd.Series([1, 2, 3, 4, 5, 6, 7, 8]) - -let apply_func = (x) => { - return x + x -} -sf.apply(apply_func).print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 2 ║ -╟───┼──────────────────────╢ -║ 1 │ 4 ║ -╟───┼──────────────────────╢ -║ 2 │ 6 ║ -╟───┼──────────────────────╢ -║ 3 │ 8 ║ -╟───┼──────────────────────╢ -║ 4 │ 10 ║ -╟───┼──────────────────────╢ -║ 5 │ 12 ║ -╟───┼──────────────────────╢ -║ 6 │ 14 ║ -╟───┼──────────────────────╢ -║ 7 │ 16 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let sf = new dfd.Series([1, 2, 3, 4, 5, 6, 7, 8]) - -sf.apply(Math.log).print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 0 ║ -╟───┼──────────────────────╢ -║ 1 │ 0.6931471805599453 ║ -╟───┼──────────────────────╢ -║ 2 │ 1.0986122886681096 ║ -╟───┼──────────────────────╢ -║ 3 │ 1.3862943611198906 ║ -╟───┼──────────────────────╢ -║ 4 │ 1.6094379124341003 ║ -╟───┼──────────────────────╢ -║ 5 │ 1.791759469228055 ║ -╟───┼──────────────────────╢ -║ 6 │ 1.9459101490553132 ║ -╟───┼──────────────────────╢ -║ 7 │ 2.0794415416798357 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let sf = new dfd.Series(["Rice","Beans","Yam","Banana","Wheat"]) - -sf.apply((x)=>{ - return x.toLocaleLowerCase() -}).print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ rice ║ -╟───┼──────────────────────╢ -║ 1 │ beans ║ -╟───┼──────────────────────╢ -║ 2 │ yam ║ -╟───┼──────────────────────╢ -║ 3 │ banana ║ -╟───┼──────────────────────╢ -║ 4 │ wheat ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/series/series.argmax.md b/api-reference-v1-stable/series/series.argmax.md deleted file mode 100644 index d7927d2..0000000 --- a/api-reference-v1-stable/series/series.argmax.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -description: Returns the int position of the largest value in the series ---- - -# Series.argmax - -> danfo.Series.argmax\(\) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L975)\] - -**Parameters**: None - -**Returns**: int - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = [1,30,20,40,50,70,90,200,10,20,12] -let sf = new dfd.Series(data) - -sf.argmax() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```text -7 -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/series/series.argmin.md b/api-reference-v1-stable/series/series.argmin.md deleted file mode 100644 index dfc661f..0000000 --- a/api-reference-v1-stable/series/series.argmin.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -description: Returns the int position of the smallest value in the series ---- - -# Series.argmin - -> danfo.Series.**argmin**\(\) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L987)\] - -**Parameters**: None - -**Returns**: int - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = [1,30,20,40,50,70,90,200,10,20,12] -let sf = new dfd.Series(data) - -sf.argmin() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```text -0 -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/series/series.argsort.md b/api-reference-v1-stable/series/series.argsort.md deleted file mode 100644 index b4608a4..0000000 --- a/api-reference-v1-stable/series/series.argsort.md +++ /dev/null @@ -1,75 +0,0 @@ ---- -description: Return the integer indices that would sort the Series values ---- - -# Series.argsort - -> danfo.Series.**argsort**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L965\\)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | -------------------------------------- | ----------------------------------------------------- | -| options | Object | **ascending**: How to sort the indices |

{
ascending: true

}

| - -**Returns:** Series (int element) - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = [10, 45, 20, 10, 23, 20, 30, 11] -let sf = new dfd.Series(data) - -sf.argsort().print() //defaults to ascending order -sf.argsort({ ascending: false }).print() - -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 0 ║ -╟───┼──────────────────────╢ -║ 1 │ 3 ║ -╟───┼──────────────────────╢ -║ 2 │ 7 ║ -╟───┼──────────────────────╢ -║ 3 │ 2 ║ -╟───┼──────────────────────╢ -║ 4 │ 5 ║ -╟───┼──────────────────────╢ -║ 5 │ 4 ║ -╟───┼──────────────────────╢ -║ 6 │ 6 ║ -╟───┼──────────────────────╢ -║ 7 │ 1 ║ -╚═══╧══════════════════════╝ - -//sorted in descending order -╔═══╤═══╗ -║ 0 │ 1 ║ -╟───┼───╢ -║ 1 │ 6 ║ -╟───┼───╢ -║ 2 │ 4 ║ -╟───┼───╢ -║ 3 │ 2 ║ -╟───┼───╢ -║ 4 │ 5 ║ -╟───┼───╢ -║ 5 │ 7 ║ -╟───┼───╢ -║ 6 │ 0 ║ -╟───┼───╢ -║ 7 │ 3 ║ -╚═══╧═══╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.astype.md b/api-reference-v1-stable/series/series.astype.md deleted file mode 100644 index 15a61ae..0000000 --- a/api-reference-v1-stable/series/series.astype.md +++ /dev/null @@ -1,2 +0,0 @@ -# Series.astype - diff --git a/api-reference-v1-stable/series/series.copy.md b/api-reference-v1-stable/series/series.copy.md deleted file mode 100644 index 9bbdb47..0000000 --- a/api-reference-v1-stable/series/series.copy.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -description: Makes a deep copy of a Series ---- - -# Series.copy - -> danfo.Series.copy() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L569)] - -**parameter:** - -**Return:** Series - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [30.21091, 40.190901, 3.564, 5.0212] -let sf1 = new dfd.Series(data1) -let sf2 = sf1.copy() - -sf2.print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 30.21091 ║ -╟───┼──────────────────────╢ -║ 1 │ 40.190901 ║ -╟───┼──────────────────────╢ -║ 2 │ 3.564 ║ -╟───┼──────────────────────╢ -║ 3 │ 5.0212 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.corr.md b/api-reference-v1-stable/series/series.corr.md deleted file mode 100644 index ee3263f..0000000 --- a/api-reference-v1-stable/series/series.corr.md +++ /dev/null @@ -1,2 +0,0 @@ -# Series.corr - diff --git a/api-reference-v1-stable/series/series.count.md b/api-reference-v1-stable/series/series.count.md deleted file mode 100644 index 832c794..0000000 --- a/api-reference-v1-stable/series/series.count.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -description: Obtain the total number of values in a series ---- - -# Series.count - -> danfo.Series.count() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L350)] - -**Parameter:** None - -**Return:** Number - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [20, 30, 1, 2, 4, 57, 89, 0, 4] -let sf1 = new dfd.Series(data1) - -console.log(sf1.count()) -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -9 -``` -{% endtab %} -{% endtabs %} - -**** diff --git a/api-reference-v1-stable/series/series.cummax.md b/api-reference-v1-stable/series/series.cummax.md deleted file mode 100644 index 8aded1a..0000000 --- a/api-reference-v1-stable/series/series.cummax.md +++ /dev/null @@ -1,51 +0,0 @@ ---- -description: Returns cumulative maximum over a series ---- - -# Series.cummax - -> danfo.Series.**cummax**(options)\[[source](https://github.com/opensource9ja/danfojs/blob/e25010c26d9c423412613d820015a48ad03d5c6d/danfojs-node/src/core/series.js#L730)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | --------------------------------------------------------------- | ------------------------------------------------------ | -| options | Object | **inplace**: Whether to perform the operation in-place or not. |

{

inplace: false

}

| - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data1 = [10, 45, 56, 25, 23, 20, 10] -let sf1 = new dfd.Series(data1) - -sf1.cummax().print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 10 ║ -╟───┼──────────────────────╢ -║ 1 │ 45 ║ -╟───┼──────────────────────╢ -║ 2 │ 56 ║ -╟───┼──────────────────────╢ -║ 3 │ 56 ║ -╟───┼──────────────────────╢ -║ 4 │ 56 ║ -╟───┼──────────────────────╢ -║ 5 │ 56 ║ -╟───┼──────────────────────╢ -║ 6 │ 56 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.cummin.md b/api-reference-v1-stable/series/series.cummin.md deleted file mode 100644 index 736cee5..0000000 --- a/api-reference-v1-stable/series/series.cummin.md +++ /dev/null @@ -1,51 +0,0 @@ ---- -description: Returns the cumulative min of a Series ---- - -# Series.cummin - -> danfo.Series.**cummin**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/e25010c26d9c423412613d820015a48ad03d5c6d/danfojs-node/src/core/series.js#L721)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | --------------------------------------------------------------- | ------------------------------------------------------ | -| options | Object | **inplace**: Whether to perform the operation in-place or not. |

{

inplace: false

}

| - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data1 = [10, 45, 56, 5, 23, 20, 10] -let sf1 = new dfd.Series(data1) - -sf1.cummin().print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 10 ║ -╟───┼──────────────────────╢ -║ 1 │ 10 ║ -╟───┼──────────────────────╢ -║ 2 │ 10 ║ -╟───┼──────────────────────╢ -║ 3 │ 5 ║ -╟───┼──────────────────────╢ -║ 4 │ 5 ║ -╟───┼──────────────────────╢ -║ 5 │ 5 ║ -╟───┼──────────────────────╢ -║ 6 │ 5 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.cumprod.md b/api-reference-v1-stable/series/series.cumprod.md deleted file mode 100644 index 84ec0e7..0000000 --- a/api-reference-v1-stable/series/series.cumprod.md +++ /dev/null @@ -1,51 +0,0 @@ ---- -description: Return the cumulative product of a series ---- - -# Series.cumprod - -> danfo.Series.**cumprod**()\[[source](https://github.com/opensource9ja/danfojs/blob/e25010c26d9c423412613d820015a48ad03d5c6d/danfojs-node/src/core/series.js#L738)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | --------------------------------------------------------------- | ------------------------------------------------------ | -| options | Object | **inplace**: Whether to perform the operation in-place or not. |

{

inplace: false

}

| - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data1 = [10, 45, 56, 25, 23, 20, 10] -let sf1 = new dfd.Series(data1) - -sf1.cumprod().print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 10 ║ -╟───┼──────────────────────╢ -║ 1 │ 450 ║ -╟───┼──────────────────────╢ -║ 2 │ 25200 ║ -╟───┼──────────────────────╢ -║ 3 │ 630000 ║ -╟───┼──────────────────────╢ -║ 4 │ 14490000 ║ -╟───┼──────────────────────╢ -║ 5 │ 289800000 ║ -╟───┼──────────────────────╢ -║ 6 │ 2898000000 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.cumsum.md b/api-reference-v1-stable/series/series.cumsum.md deleted file mode 100644 index 7b7a19a..0000000 --- a/api-reference-v1-stable/series/series.cumsum.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -description: Return a cumulative sum of a series ---- - -# Series.cumsum - -> danfo.Series.**cumsum**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/e25010c26d9c423412613d820015a48ad03d5c6d/danfojs-node/src/core/series.js#L713)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | --------------------------------------------------------------- | ------------------------------------------------------ | -| options | Object | **inplace**: Whether to perform the operation in-place or not. |

{

inplace: false

}

| - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data1 = [10, 45, 56, 25, 23, 20, 10] -let sf1 = new dfd.Series(data1) - -sf1.cumsum().print() -``` -{% endtab %} - -{% tab title="Browser" %} -```markup - - - - - - - - Document - - - - - - - - - -``` -{% endtab %} -{% endtabs %} - -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 10 ║ -╟───┼──────────────────────╢ -║ 1 │ 55 ║ -╟───┼──────────────────────╢ -║ 2 │ 111 ║ -╟───┼──────────────────────╢ -║ 3 │ 136 ║ -╟───┼──────────────────────╢ -║ 4 │ 159 ║ -╟───┼──────────────────────╢ -║ 5 │ 179 ║ -╟───┼──────────────────────╢ -║ 6 │ 189 ║ -╚═══╧══════════════════════╝ -``` diff --git a/api-reference-v1-stable/series/series.describe.md b/api-reference-v1-stable/series/series.describe.md deleted file mode 100644 index ce52246..0000000 --- a/api-reference-v1-stable/series/series.describe.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -description: >- - Generate descriptive statistics. Descriptive statistics include those that - summarize the central tendency, dispersion and shape of a dataset’s - distribution, excluding NaN values ---- - -# Series.describe - -> danfo.Series.describe() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L583)] - -**Parameters:** No parameter - -**return:** Series - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = [1,2,3,4,5,6] -let sf = new dfd.Series(data) -sf.describe().print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔══════════╤══════════════════════╗ -║ │ 0 ║ -╟──────────┼──────────────────────╢ -║ count │ 6 ║ -╟──────────┼──────────────────────╢ -║ mean │ 3.5 ║ -╟──────────┼──────────────────────╢ -║ std │ 1.8708286933869707 ║ -╟──────────┼──────────────────────╢ -║ min │ 1 ║ -╟──────────┼──────────────────────╢ -║ median │ 3.5 ║ -╟──────────┼──────────────────────╢ -║ max │ 6 ║ -╟──────────┼──────────────────────╢ -║ variance │ 3.5 ║ -╚══════════╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.div.md b/api-reference-v1-stable/series/series.div.md deleted file mode 100644 index 656a796..0000000 --- a/api-reference-v1-stable/series/series.div.md +++ /dev/null @@ -1,87 +0,0 @@ ---- -description: >- - Return Floating division of series and other, element-wise (binary operator - truediv). ---- - -# Series.div - -> danfo.Series.div(other, options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L188)] - -| Parameters | Type | Description | Default | -| ---------- | ------------- | ---------------------------------------------------------------------------------------------- | ------------------------------------- | -| other | Series\|int\| | values | | -| options | Object | inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false |

{

inplace: false

}

| - -**Return:** Series - -**Example** - -divide with values of another series - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [30, 40, 3, 5] -let data2 = [1, 2, 3, 4] -let sf1 = new dfd.Series(data1) -let sf2 = new dfd.Series(data2) -sf1.div(sf2).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 30 ║ -╟───┼──────────────────────╢ -║ 1 │ 20 ║ -╟───┼──────────────────────╢ -║ 2 │ 1 ║ -╟───┼──────────────────────╢ -║ 3 │ 1.25 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### divide with a value - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [1, 2, 3, 4, 5] -let sf1 = new dfd.Series(data1) - -sf1.div(2).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 0.5 ║ -╟───┼──────────────────────╢ -║ 1 │ 1 ║ -╟───┼──────────────────────╢ -║ 2 │ 1.5 ║ -╟───┼──────────────────────╢ -║ 3 │ 2 ║ -╟───┼──────────────────────╢ -║ 4 │ 2.5 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.dot.md b/api-reference-v1-stable/series/series.dot.md deleted file mode 100644 index 61a8bc2..0000000 --- a/api-reference-v1-stable/series/series.dot.md +++ /dev/null @@ -1,2 +0,0 @@ -# Series.dot - diff --git a/api-reference-v1-stable/series/series.drop_duplicates.md b/api-reference-v1-stable/series/series.drop_duplicates.md deleted file mode 100644 index 08edf09..0000000 --- a/api-reference-v1-stable/series/series.drop_duplicates.md +++ /dev/null @@ -1,121 +0,0 @@ ---- -description: Remove duplicate rows ---- - -# Series.drop\_duplicates - -> danfo.Series.**drop\_duplicates**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L1007)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------- | -| options | Object |

keep: "first" | "last", which duplicate value to keep. Defaults to "first".
inplace: Boolean indicating whether to perform the operation in-place or not. Defaults to false

|

{

inplace: false

}

| - -**Returns:** Series - -**Examples** - -### Drop duplicate by keeping the first occurrence of the duplicate value - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [10, 45, 56, 10, 23, 20, 10, 10] -let sf = new dfd.Series(data1) -let sf_drop = sf.drop_duplicates() - -sf_drop.print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 10 ║ -╟───┼──────────────────────╢ -║ 1 │ 45 ║ -╟───┼──────────────────────╢ -║ 2 │ 56 ║ -╟───┼──────────────────────╢ -║ 4 │ 23 ║ -╟───┼──────────────────────╢ -║ 5 │ 20 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Drop duplicate and keep only the last duplicated value - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [10, 45, 56, 10, 23, 20, 10, 10] -let sf = new dfd.Series(data1) -let sf_drop = sf.drop_duplicates({keep:"last"}) - -sf_drop.print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 1 │ 45 ║ -╟───┼──────────────────────╢ -║ 2 │ 56 ║ -╟───┼──────────────────────╢ -║ 4 │ 23 ║ -╟───┼──────────────────────╢ -║ 5 │ 20 ║ -╟───┼──────────────────────╢ -║ 7 │ 10 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Remove duplicate value in-place - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = ["A", "A", "A", "B", "B", "C", "C", "D"] -let sf = new dfd.Series(data1) -sf.drop_duplicates({inplace:true}) - -sf.print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ A ║ -╟───┼──────────────────────╢ -║ 3 │ B ║ -╟───┼──────────────────────╢ -║ 5 │ C ║ -╟───┼──────────────────────╢ -║ 7 │ D ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.dropna.md b/api-reference-v1-stable/series/series.dropna.md deleted file mode 100644 index 2fab716..0000000 --- a/api-reference-v1-stable/series/series.dropna.md +++ /dev/null @@ -1,91 +0,0 @@ ---- -description: Remove missing values from Series ---- - -# Series.dropna - -> danfo.Series.**dropna**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L931)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ---------------------------------------------------------------------------------------------- | ----------------------------------- | -| options | Object | inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false |

{
inplace: false

}

| - -**Returns**: Series - -**Examples** - -### Drop all nan value and then return New Series. - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [10, 45, undefined, 10, 23, 20, undefined, 10] -let sf = new dfd.Series(data1) -let sf_rep = sf.dropna() - -sf_rep.print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 10 ║ -╟───┼──────────────────────╢ -║ 1 │ 45 ║ -╟───┼──────────────────────╢ -║ 3 │ 10 ║ -╟───┼──────────────────────╢ -║ 4 │ 23 ║ -╟───┼──────────────────────╢ -║ 5 │ 20 ║ -╟───┼──────────────────────╢ -║ 7 │ 10 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Drop nan values in-place - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [10, 45, undefined, 10, 23, 20, undefined, 10] -let sf = new dfd.Series(data1) -sf.dropna({inplace:true}) - -sf.print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 10 ║ -╟───┼──────────────────────╢ -║ 1 │ 45 ║ -╟───┼──────────────────────╢ -║ 3 │ 10 ║ -╟───┼──────────────────────╢ -║ 4 │ 23 ║ -╟───┼──────────────────────╢ -║ 5 │ 20 ║ -╟───┼──────────────────────╢ -║ 7 │ 10 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.dt.day.md b/api-reference-v1-stable/series/series.dt.day.md deleted file mode 100644 index 6461fa5..0000000 --- a/api-reference-v1-stable/series/series.dt.day.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -description: Obtain the numerical representation of the week day. ---- - -# Series.dt.day - -> danfo.Series.dt.**day**() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/timeseries.js#L216)] - -**Parameters**: None - -**Returns:** Series (int elements) - -**Examples** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = new dfd.date_range({"start":'2016-12-31', "end":'2018-01-08'}) -let sf = new dfd.Series(data) - -sf.dt.day().print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -``` -╔═══╤═══╗ -║ 0 │ 6 ║ -╟───┼───╢ -║ 1 │ 0 ║ -╟───┼───╢ -║ 2 │ 1 ║ -╟───┼───╢ -║ 3 │ 2 ║ -╟───┼───╢ -║ 4 │ 3 ║ -╟───┼───╢ -║ 5 │ 4 ║ -╟───┼───╢ -║ 6 │ 5 ║ -╟───┼───╢ -║ 7 │ 6 ║ -╟───┼───╢ -║ 8 │ 0 ║ -╟───┼───╢ -║ 9 │ 1 ║ -╚═══╧═══╝ -``` diff --git a/api-reference-v1-stable/series/series.dt.hour.md b/api-reference-v1-stable/series/series.dt.hour.md deleted file mode 100644 index 16369bb..0000000 --- a/api-reference-v1-stable/series/series.dt.hour.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -description: Obtain the hours in a time series ---- - -# Series.dt.hour - -> danfo.Series.dt.**hour**() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/timeseries.js#L205)] - -**Parameters:** None - -**Returns:** Series (int elements) - -**Examples** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = new dfd.date_range({"start":"2000-01-01", period:3, freq:"H"}) -let sf = new dfd.Series(data) -// print series -sf.print() -// print hour series -sf.dt.hours().print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ 0 │ 1/1/2000, 1:00:00 AM ║ -╟───┼──────────────────────╢ -║ 1 │ 1/1/2000, 2:00:00 AM ║ -╚═══╧══════════════════════╝ - -╔═══╤═══╗ -║ 0 │ 1 ║ -╟───┼───╢ -║ 1 │ 2 ║ -╚═══╧═══╝ - -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.dt.minute.md b/api-reference-v1-stable/series/series.dt.minute.md deleted file mode 100644 index ea8bfee..0000000 --- a/api-reference-v1-stable/series/series.dt.minute.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -description: Obtain the minutes in a Time Series ---- - -# Series.dt.minutes - -> danfo.Series.dt.**minutes**() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/timeseries.js#L292)] - -**Parameters**: None - -**Returns:** Series (int Elements) - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = new dfd.date_range({"start":"2000-01-01", period:3, freq:"m"}) -let sf = new dfd.Series(data) -//print the series -sf.print() -//print the minutes series -sf.dt.minutes().print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 1/1/2000, 1:00:00 AM ║ -╟───┼──────────────────────╢ -║ 1 │ 1/1/2000, 1:01:00 AM ║ -╟───┼──────────────────────╢ -║ 2 │ 1/1/2000, 1:02:00 AM ║ -╚═══╧══════════════════════╝ - -//print the minutes series -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 0 ║ -╟───┼──────────────────────╢ -║ 1 │ 1 ║ -╟───┼──────────────────────╢ -║ 2 │ 2 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.dt.month.md b/api-reference-v1-stable/series/series.dt.month.md deleted file mode 100644 index e21eeda..0000000 --- a/api-reference-v1-stable/series/series.dt.month.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -description: Obtain the month in a date time series ---- - -# Series.dt.month - -> danfo.Series.dt.**month**() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/timeseries.js#L193)] - -**Parameters**: None - -**Returns:** Series (int elements) - -**Examples** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = new dfd.date_range({"start":'2016-7-31', "end":'2016-12-08', freq:"M"}) -let sf = new dfd.Series(data) - -sf.dt.month().print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -``` -╔═══╤════╗ -║ 0 │ 6 ║ -╟───┼────╢ -║ 1 │ 7 ║ -╟───┼────╢ -║ 2 │ 9 ║ -╟───┼────╢ -║ 3 │ 9 ║ -╟───┼────╢ -║ 4 │ 11 ║ -╟───┼────╢ -║ 5 │ 11 ║ -╚═══╧════╝ -``` diff --git a/api-reference-v1-stable/series/series.dt.month_name.md b/api-reference-v1-stable/series/series.dt.month_name.md deleted file mode 100644 index 4e83618..0000000 --- a/api-reference-v1-stable/series/series.dt.month_name.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -description: obtain the month name in a Time Series ---- - -# Series.dt.month\_name - -> danfo.Series.dt.month\_name() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/timeseries.js#L241)] - -**Parameters**: None - -**Returns:** Series (String elements) - -**Examples** - -{% tabs %} -{% tab title="Output" %} -```javascript -const dfd = require("danfojs-node") - -let data = new dfd.date_range({"start":'2018-01', freq:'M', period:3}) -let sf = new dfd.Series(data) -//print series -sf.print() -//print month names -sf.dt.month_name().print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ 0 │ 1/1/2018, 1:00:00 AM ║ -╟───┼──────────────────────╢ -║ 1 │ 2/1/2018, 1:00:00 AM ║ -╟───┼──────────────────────╢ -║ 2 │ 3/1/2018, 1:00:00 AM ║ -╚═══╧══════════════════════╝ - -╔═══╤═════╗ -║ 0 │ Jan ║ -╟───┼─────╢ -║ 1 │ Feb ║ -╟───┼─────╢ -║ 2 │ Mar ║ -╚═══╧═════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.dt.monthday.md b/api-reference-v1-stable/series/series.dt.monthday.md deleted file mode 100644 index b385f17..0000000 --- a/api-reference-v1-stable/series/series.dt.monthday.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -description: Obtain the day of the month ---- - -# Series.dt.monthday - -> danfo.Series.dt.**monthday**() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/timeseries.js#L268)] - -**Parameters:** None - -**Returns**: Series (Int elements) - -**Examples** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = new dfd.date_range({"start":"2000-01-01", period:4, freq:"D"}) -let sf = new dfd.Series(data) -//print series -sf.print() -//print monthdays -sf.dt.monthday().print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ 0 │ 1/1/2000, 1:00:00 AM ║ -╟───┼──────────────────────╢ -║ 1 │ 1/2/2000, 1:00:00 AM ║ -╟───┼──────────────────────╢ -║ 2 │ 1/3/2000, 1:00:00 AM ║ -╚═══╧══════════════════════╝ - -╔═══╤═══╗ -║ 0 │ 1 ║ -╟───┼───╢ -║ 1 │ 2 ║ -╟───┼───╢ -║ 2 │ 3 ║ -╚═══╧═══╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.dt.second.md b/api-reference-v1-stable/series/series.dt.second.md deleted file mode 100644 index 43330be..0000000 --- a/api-reference-v1-stable/series/series.dt.second.md +++ /dev/null @@ -1,60 +0,0 @@ ---- -description: Obtain the seconds in Date series ---- - -# Series.dt.seconds - -> danfo.Series.dt.**seconds**() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/timeseries.js#L280)] - -**Parameters**: None - -**Returns:** Series (Int elements) - -**Example** - -Obtain the seconds of the datetime - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = new dfd.date_range({"start":"2000-01-01", period:3, freq:"s"}) -let sf = new dfd.Series(data) -//print the series frame -sf.print() - -//print the seconds obtained -sf.dt.seconds().print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` - -╔═══╤══════════════════════╗ -║ 0 │ 1/1/2000, 1:00:00 AM ║ -╟───┼──────────────────────╢ -║ 1 │ 1/1/2000, 1:00:01 AM ║ -╟───┼──────────────────────╢ -║ 2 │ 1/1/2000, 1:00:02 AM ║ -╚═══╧══════════════════════╝ - -╔═══╤═══╗ -║ 0 │ 0 ║ -╟───┼───╢ -║ 1 │ 1 ║ -╟───┼───╢ -║ 2 │ 2 ║ -╚═══╧═══╝ - -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.dt.weekdays.md b/api-reference-v1-stable/series/series.dt.weekdays.md deleted file mode 100644 index 04dbe18..0000000 --- a/api-reference-v1-stable/series/series.dt.weekdays.md +++ /dev/null @@ -1,79 +0,0 @@ ---- -description: Obtain the days of the weeks ---- - -# Series.dt.weekdays - -> danfo.Series.dt.**weekdays**() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/timeseries.js#L255)] - -**Parameters**: None - -**Returns:** Series (String elements) - -**Examples** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = new dfd.date_range({"start":'2016-12-31', "end":'2017-01-08'}) -let sf = new dfd.Series(data) -//print series -sf.print() -//print days of the week -sf.dt.weekdays().print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -``` -╔═══╤════════════════════════╗ -║ 0 │ 12/31/2016, 1:00:00 AM ║ -╟───┼────────────────────────╢ -║ 1 │ 1/1/2017, 1:00:00 AM ║ -╟───┼────────────────────────╢ -║ 2 │ 1/2/2017, 1:00:00 AM ║ -╟───┼────────────────────────╢ -║ 3 │ 1/3/2017, 1:00:00 AM ║ -╟───┼────────────────────────╢ -║ 4 │ 1/4/2017, 1:00:00 AM ║ -╟───┼────────────────────────╢ -║ 5 │ 1/5/2017, 1:00:00 AM ║ -╟───┼────────────────────────╢ -║ 6 │ 1/6/2017, 1:00:00 AM ║ -╟───┼────────────────────────╢ -║ 7 │ 1/7/2017, 1:00:00 AM ║ -╟───┼────────────────────────╢ -║ 8 │ 1/8/2017, 1:00:00 AM ║ -╟───┼────────────────────────╢ -║ 9 │ 1/9/2017, 1:00:00 AM ║ -╚═══╧════════════════════════╝ - -╔═══╤══════╗ -║ 0 │ Sat ║ -╟───┼──────╢ -║ 1 │ Sun ║ -╟───┼──────╢ -║ 2 │ Mon ║ -╟───┼──────╢ -║ 3 │ Tue ║ -╟───┼──────╢ -║ 4 │ Wed ║ -╟───┼──────╢ -║ 5 │ Thur ║ -╟───┼──────╢ -║ 6 │ Fri ║ -╟───┼──────╢ -║ 7 │ Sat ║ -╟───┼──────╢ -║ 8 │ Sun ║ -╟───┼──────╢ -║ 9 │ Mon ║ -╚═══╧══════╝ -``` diff --git a/api-reference-v1-stable/series/series.dt.year.md b/api-reference-v1-stable/series/series.dt.year.md deleted file mode 100644 index ed1117f..0000000 --- a/api-reference-v1-stable/series/series.dt.year.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -description: Obtain the year in a date time series ---- - -# Series.dt.year - -> danfo.Series.dt.**year**() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/timeseries.js#L228)] - -**Parameters**: None - -**Returns:** Series (int elements) - -**Examples** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = new dfd.date_range({"start":"2000-01-01", period:3, freq:"Y"}) -let sf = new dfd.Series(data) -sf.print() -sf.dt.year().print() -``` -{% endtab %} -{% endtabs %} - -``` -//print date time series -╔═══╤══════════════════════╗ -║ 0 │ 1/1/2000, 1:00:00 AM ║ -╟───┼──────────────────────╢ -║ 1 │ 1/1/2001, 1:00:00 AM ║ -╟───┼──────────────────────╢ -║ 2 │ 1/1/2002, 1:00:00 AM ║ -╚═══╧══════════════════════╝ - -╔═══╤══════╗ -║ 0 │ 2000 ║ -╟───┼──────╢ -║ 1 │ 2001 ║ -╟───┼──────╢ -║ 2 │ 2002 ║ -╚═══╧══════╝ -``` diff --git a/api-reference-v1-stable/series/series.dtype.md b/api-reference-v1-stable/series/series.dtype.md deleted file mode 100644 index 75b4614..0000000 --- a/api-reference-v1-stable/series/series.dtype.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -description: Obtain the dtype of a series ---- - -# Series.dtype - -> danfo.Series.dtype \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/generic.js#L197)] - -**Parameters**: None - -**Returns:** String - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [30.21091, 40.190901, 3.564, 5.0212] -let sf1 = new dfd.Series(data1) - -console.log(sf1.dtype) -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -float32 -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.eq.md b/api-reference-v1-stable/series/series.eq.md deleted file mode 100644 index 43a3ece..0000000 --- a/api-reference-v1-stable/series/series.eq.md +++ /dev/null @@ -1,95 +0,0 @@ ---- -description: Check all the values in a series is equal to another value ---- - -# Series.eq - -> danfo.Series.eq(other) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L894)] - -| Parameters | Type | Description | Default | -| ---------- | ----------------------- | ----------------- | ------- | -| other | Series, Array or number | value to compare | | - -**Returns**: Series (Boolean element) - -**Examples** - -Compare all the values in a series to another series - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [10, 45, 56, 25, 23, 20, 10] -let data2 = [10, 450, 56, 5, 25, 2, 0] -let sf1 = new dfd.Series(data1) -let sf2 = new dfd.Series(data2) - -sf1.eq(sf2).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ true ║ -╟───┼──────────────────────╢ -║ 1 │ false ║ -╟───┼──────────────────────╢ -║ 2 │ true ║ -╟───┼──────────────────────╢ -║ 3 │ false ║ -╟───┼──────────────────────╢ -║ 4 │ false ║ -╟───┼──────────────────────╢ -║ 5 │ false ║ -╟───┼──────────────────────╢ -║ 6 │ false ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -Check it all the values are equal to a value - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [10, 45, 56, 25, 23, 20, 10] -let sf1 = new dfd.Series(data1) - -sf1.eq(10).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ true ║ -╟───┼──────────────────────╢ -║ 1 │ false ║ -╟───┼──────────────────────╢ -║ 2 │ false ║ -╟───┼──────────────────────╢ -║ 3 │ false ║ -╟───┼──────────────────────╢ -║ 4 │ false ║ -╟───┼──────────────────────╢ -║ 5 │ false ║ -╟───┼──────────────────────╢ -║ 6 │ true ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.fillna.md b/api-reference-v1-stable/series/series.fillna.md deleted file mode 100644 index a1db3a8..0000000 --- a/api-reference-v1-stable/series/series.fillna.md +++ /dev/null @@ -1,106 +0,0 @@ ---- -description: Replace all NaN value with specified value ---- - -# Series.fillna - -> danfo.Series.**fillna**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L470)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | -| options | Object |

value: The value to replace all missing value with.

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

|

{

inplace: false

}

| - -**Examples** - -### Fill nan value and then return new series - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [NaN, 1, 2, 33, 4, NaN, 5, 6, 7, 8] -let sf = new dfd.Series(data1) - -let sf_rep = sf.fillna({ value: -999}) - -sf_rep.print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ -999 ║ -╟───┼──────────────────────╢ -║ 1 │ 1 ║ -╟───┼──────────────────────╢ -║ 2 │ 2 ║ -╟───┼──────────────────────╢ -║ 3 │ 33 ║ -╟───┼──────────────────────╢ -║ 4 │ 4 ║ -╟───┼──────────────────────╢ -║ 5 │ -999 ║ -╟───┼──────────────────────╢ -║ 6 │ 5 ║ -╟───┼──────────────────────╢ -║ 7 │ 6 ║ -╟───┼──────────────────────╢ -║ 8 │ 7 ║ -╟───┼──────────────────────╢ -║ 9 │ 8 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Fill nan value in-place - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [NaN, 1, 2, 33, 4, NaN, 5, 6, 7, 8] -let sf = new dfd.Series(data1) -sf.fillna({ value: -999, inplace: true }) - -sf.print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ -999 ║ -╟───┼──────────────────────╢ -║ 1 │ 1 ║ -╟───┼──────────────────────╢ -║ 2 │ 2 ║ -╟───┼──────────────────────╢ -║ 3 │ 33 ║ -╟───┼──────────────────────╢ -║ 4 │ 4 ║ -╟───┼──────────────────────╢ -║ 5 │ -999 ║ -╟───┼──────────────────────╢ -║ 6 │ 5 ║ -╟───┼──────────────────────╢ -║ 7 │ 6 ║ -╟───┼──────────────────────╢ -║ 8 │ 7 ║ -╟───┼──────────────────────╢ -║ 9 │ 8 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.ge.md b/api-reference-v1-stable/series/series.ge.md deleted file mode 100644 index 0fb1aeb..0000000 --- a/api-reference-v1-stable/series/series.ge.md +++ /dev/null @@ -1,95 +0,0 @@ ---- -description: Check if all the values in a series is greater than or equal a value ---- - -# Series.ge - -> danfo.Series.ge(other) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L874)] - -| Parameters | Type | Description | Default | -| ---------- | ----------------------- | ------------------- | ------- | -| other | Series, Array or number | value(s) to compare | | - -**Returns:** Series (Boolean element) - -**Example** - -Compare all the value in a Series to the values in another series - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [10, 45, 56, 25, 23, 20, 10] -let data2 = [10, 450, 56, 5, 25, 2, 0] -let sf1 = new dfd.Series(data1) -let sf2 = new dfd.Series(data2) - -sf1.ge(sf2).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ true ║ -╟───┼──────────────────────╢ -║ 1 │ false ║ -╟───┼──────────────────────╢ -║ 2 │ true ║ -╟───┼──────────────────────╢ -║ 3 │ true ║ -╟───┼──────────────────────╢ -║ 4 │ false ║ -╟───┼──────────────────────╢ -║ 5 │ true ║ -╟───┼──────────────────────╢ -║ 6 │ true ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -Check if all the value in a Series is greater than or equal a value. - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [10, 45, 56, 25, 23, 20, 10] -let sf1 = new dfd.Series(data1) - -sf1.ge(20).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ false ║ -╟───┼──────────────────────╢ -║ 1 │ true ║ -╟───┼──────────────────────╢ -║ 2 │ true ║ -╟───┼──────────────────────╢ -║ 3 │ true ║ -╟───┼──────────────────────╢ -║ 4 │ true ║ -╟───┼──────────────────────╢ -║ 5 │ true ║ -╟───┼──────────────────────╢ -║ 6 │ false ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.gt.md b/api-reference-v1-stable/series/series.gt.md deleted file mode 100644 index 184ca28..0000000 --- a/api-reference-v1-stable/series/series.gt.md +++ /dev/null @@ -1,95 +0,0 @@ ---- -description: Check if all the value in a series is greater than a value ---- - -# Series.gt - -> danfo.Series.gt(other) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L856)] - -| Parameters | Type | Description | Default | -| ---------- | ----------------------- | ------------------- | ------- | -| other | Series, Array or number | value(s) to compare | | - -**Returns**: Series (boolean element) - -**Example** - -Check if all the values in a series are greater than a value - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [10, 45, 56, 25, 23, 20, 10] -let sf1 = new dfd.Series(data1) - -sf1.gt(20).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ false ║ -╟───┼──────────────────────╢ -║ 1 │ true ║ -╟───┼──────────────────────╢ -║ 2 │ true ║ -╟───┼──────────────────────╢ -║ 3 │ true ║ -╟───┼──────────────────────╢ -║ 4 │ true ║ -╟───┼──────────────────────╢ -║ 5 │ false ║ -╟───┼──────────────────────╢ -║ 6 │ false ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -check if all the values in a series are greater than values in another series. - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [10, 45, 56, 25, 23, 20, 10] -let data2 = [10, 450, 56, 5, 25, 2, 0] -let sf1 = new dfd.Series(data1) -let sf2 = new dfd.Series(data2) - -sf1.gt(sf2).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ false ║ -╟───┼──────────────────────╢ -║ 1 │ false ║ -╟───┼──────────────────────╢ -║ 2 │ false ║ -╟───┼──────────────────────╢ -║ 3 │ true ║ -╟───┼──────────────────────╢ -║ 4 │ false ║ -╟───┼──────────────────────╢ -║ 5 │ true ║ -╟───┼──────────────────────╢ -║ 6 │ true ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.head.md b/api-reference-v1-stable/series/series.head.md deleted file mode 100644 index 2892263..0000000 --- a/api-reference-v1-stable/series/series.head.md +++ /dev/null @@ -1,51 +0,0 @@ ---- -description: Obtain the first n rows for the object based on position. ---- - -# Series.head - -> danfo.Series.head\(rows\) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L76)\] - -| Parameters | Type | Description | Default | -| :--- | :--- | :--- | :--- | -| rows | Int | number of first n values | 5 | - - **Return:** Series - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [1, 2, 3, 4, 5, 620, 30, 40, 39, 89, 78] -let sf1 = new dfd.Series(data1) - -sf1.head().print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```text -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 1 ║ -╟───┼──────────────────────╢ -║ 1 │ 2 ║ -╟───┼──────────────────────╢ -║ 2 │ 3 ║ -╟───┼──────────────────────╢ -║ 3 │ 4 ║ -╟───┼──────────────────────╢ -║ 4 │ 5 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - - - diff --git a/api-reference-v1-stable/series/series.iloc.md b/api-reference-v1-stable/series/series.iloc.md deleted file mode 100644 index ab7d1f3..0000000 --- a/api-reference-v1-stable/series/series.iloc.md +++ /dev/null @@ -1,158 +0,0 @@ -# Series.iloc - -danfo.Series.**iloc**() \[[source](https://github.com/opensource9ja/danfojs/blob/fe56860b0a303d218d60ba71dee6abf594401556/danfojs/src/core/frame.js#L254)] - -| Parameters | Type | Description | Default | -| ---------- | -------------- | ----------------------------------------------------------------------- | ------- | -| rows | Array, String | Array, string slice, index of row positions boolean mask to filter by. | | - -**Returns:** - - **** return **Series** - -## **Examples** - -`.iloc()` is primarily integer position based (from `0` to `length-1` of the axis). - -Allowed inputs are: - -* An integer, e.g. `5`. -* A list or array of integers, e.g. `[4, 3, 0]`. -* A boolean mask. E.g \[ true, false, false ] -* A string slice object with ints, e.g. `"1:7"` - -_**Note:** only **** the start label is included, and the end label is ignored._ - -`.iloc` will raise`IndexError` if a requested indexer is out-of-bounds. - -### **Indexing specific rows by index** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let s = new dfd.Series([12, 34, 2.2, 2, 30, 30, 2.1, 7]) -s.iloc([0,5]).print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 12 ║ -╟───┼──────────────────────╢ -║ 5 │ 30 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### **Index by a slice of row** - -The [**iloc**](../dataframe/danfo.dataframe.iloc.md) function also accepts string slices of the form \[start: end], e.g "\[0: 5]". This will return all values from index positions 0 to 4. - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let s = new dfd.Series([12, 34, 2.2, 2, 30, 30, 2.1, 7]) -s.iloc(["0:5"]).print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 12 ║ -╟───┼──────────────────────╢ -║ 1 │ 34 ║ -╟───┼──────────────────────╢ -║ 2 │ 2.2 ║ -╟───┼──────────────────────╢ -║ 3 │ 2 ║ -╟───┼──────────────────────╢ -║ 4 │ 30 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -By specifying a start index in a slice, all values after that index are returned. - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let s = new dfd.Series([12, 34, 2.2, 2, 30, 30, 2.1, 7]) -s.iloc(["5:"]).print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 5 │ 30 ║ -╟───┼──────────────────────╢ -║ 6 │ 2.1 ║ -╟───┼──────────────────────╢ -║ 7 │ 7 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Slice Series by boolean condition - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let s = new dfd.Series([12, 34, 2.2, 2, 30, 30, 2.1, 7]) -s.iloc(s.gt(20)).print() -``` -{% endtab %} -{% endtabs %} - -``` -╔═══╤════╗ -║ 1 │ 34 ║ -╟───┼────╢ -║ 4 │ 30 ║ -╟───┼────╢ -║ 5 │ 30 ║ -╚═══╧════╝ -``` diff --git a/api-reference-v1-stable/series/series.index.md b/api-reference-v1-stable/series/series.index.md deleted file mode 100644 index 1cc95da..0000000 --- a/api-reference-v1-stable/series/series.index.md +++ /dev/null @@ -1,33 +0,0 @@ ---- -description: Obtain the index of a Series ---- - -# Series.index - -> danfo.Series.index \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/generic.js#L234)\] - -**Returns**: Array - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [30.21091, 40.190901, 3.564, 5.0212] -let sf1 = new dfd.Series(data1) - -console.log(sf1.index) -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```text -[ 0, 1, 2, 3 ] -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/series/series.isna.md b/api-reference-v1-stable/series/series.isna.md deleted file mode 100644 index cdf6343..0000000 --- a/api-reference-v1-stable/series/series.isna.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -description: Detect Missing values ---- - -# Series.isna - -> danfo.Series.**isna**\(\) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L449)\] - -**Parameters**: None - -**Returns**: Series \(Boolean element\) - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [NaN, undefined, "girl", "Man"] -let sf = new dfd.Series(data1) - -sf.isna().print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```text -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ true ║ -╟───┼──────────────────────╢ -║ 1 │ true ║ -╟───┼──────────────────────╢ -║ 2 │ false ║ -╟───┼──────────────────────╢ -║ 3 │ false ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/series/series.le.md b/api-reference-v1-stable/series/series.le.md deleted file mode 100644 index 44006e2..0000000 --- a/api-reference-v1-stable/series/series.le.md +++ /dev/null @@ -1,96 +0,0 @@ ---- -description: Check if all the values in a series is less than or equal to a value ---- - -# Series.le - -> danfo.Series.le(other) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L865)] - -| Parameters | Type | Description | Default | -| ---------- | ----------------------- | ------------------- | ------- | -| other | Series, Array or number | value(s) to compare | | - -**Returns:** Series (Boolean Element) - -**Example** - -Check if all the values in a series is less than or equal to a value - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [10, 45, 56, 25, 23, 20, 10] -let sf1 = new dfd.Series(data1) - -sf1.le(20).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ true ║ -╟───┼──────────────────────╢ -║ 1 │ false ║ -╟───┼──────────────────────╢ -║ 2 │ false ║ -╟───┼──────────────────────╢ -║ 3 │ false ║ -╟───┼──────────────────────╢ -║ 4 │ false ║ -╟───┼──────────────────────╢ -║ 5 │ true ║ -╟───┼──────────────────────╢ -║ 6 │ true ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -check if all the values in a series are less than equal to values in another series. - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [10, 45, 56, 25, 23, 20, 10] -let data2 = [10, 450, 56, 5, 25, 2, 0] -let sf1 = new dfd.Series(data1) -let sf2 = new dfd.Series(data2) - -sf1.le(sf2).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ true ║ -╟───┼──────────────────────╢ -║ 1 │ true ║ -╟───┼──────────────────────╢ -║ 2 │ true ║ -╟───┼──────────────────────╢ -║ 3 │ false ║ -╟───┼──────────────────────╢ -║ 4 │ true ║ -╟───┼──────────────────────╢ -║ 5 │ false ║ -╟───┼──────────────────────╢ -║ 6 │ false ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/series/series.loc.md b/api-reference-v1-stable/series/series.loc.md deleted file mode 100644 index 13772ab..0000000 --- a/api-reference-v1-stable/series/series.loc.md +++ /dev/null @@ -1,198 +0,0 @@ ---- -description: Access a group of rows by label(s) or a boolean array. ---- - -# Series.loc - -danfo.Series.**loc**() \[[source](https://github.com/opensource9ja/danfojs/blob/fe56860b0a303d218d60ba71dee6abf594401556/danfojs/src/core/frame.js#L254)] - -| Parameters | Type | Description | Default | -| ---------- | -------------- | ----------------------------------------------------------------------- | ------- | -| rows | Array, String | Array, string slice, index of row positions boolean mask to filter by. | | - -**Returns:** - - **** return **Series** - -## **Examples** - -`.loc()` is label position based (from `0` to `length-1` of the row axis). - -Allowed inputs are: - -* An integer, e.g. `"r1"`. -* A list or array of integers, e.g. `["a", "b", "d"]`. -* A boolean mask. E.g \[ true, false, false ] -* A string slice object with ints, e.g. `[`'`"a":"d"'], ["1:4"]` - -_**Note:** only **** the start label is included, and the end label is ignored._ - -`.loc` will raise a `ValueEror` if a requested label is not found. - -### **Indexing by specific row index** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -const data = [12, 34, 2.2, 2, 30, 30, 2.1, 7] -const index = ["a", "b", "c", "d", "e", "f", "g", "h"] -let s = new dfd.Series(data, { index }) -s.print() - -s.loc(["a", "g"]).print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═════╗ -║ a │ 12 ║ -╟───┼─────╢ -║ b │ 34 ║ -╟───┼─────╢ -║ c │ 2.2 ║ -╟───┼─────╢ -║ d │ 2 ║ -╟───┼─────╢ -║ e │ 30 ║ -╟───┼─────╢ -║ f │ 30 ║ -╟───┼─────╢ -║ g │ 2.1 ║ -╟───┼─────╢ -║ h │ 7 ║ -╚═══╧═════╝ - -╔═══╤═════╗ -║ a │ 12 ║ -╟───┼─────╢ -║ g │ 2.1 ║ -╚═══╧═════╝ -``` -{% endtab %} -{% endtabs %} - -### **Index by a slice of row** - -The **loc** function also accepts string slices of the form \[start: end], e.g **\[\`"a":"e"\`]**. This will return all values from label positions `a` to `e`. - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -const data = [12, 34, 2.2, 2, 30, 30, 2.1, 7] -const index = ["a", "b", "c", "d", "e", "f", "g", "h"] -let s = new dfd.Series(data, { index }) -s.print() - -s.loc([`"a":"e"`]).print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═════╗ -║ a │ 12 ║ -╟───┼─────╢ -║ b │ 34 ║ -╟───┼─────╢ -║ c │ 2.2 ║ -╟───┼─────╢ -║ d │ 2 ║ -╚═══╧═════╝ -``` -{% endtab %} -{% endtabs %} - -{% hint style="info" %} -Note that when using loc. We expect you to pass labels in the correct format. That is, string labels must be explicitly quoted. For example, the following loc slice will throw an error:\ -`s.loc([a:e]).print()`\ -For the slice above to work, you must quote each slice, e.g:\ -`s.loc(["a":"e"]).print()`\ -\ -_**Inner quotes are not needed for numeric indices!**_ -{% endhint %} - -### By specifying a start index in a slice, all values after that index are returned. - -{% tabs %} -{% tab title="Node" %} -```javascript -const data = [12, 34, 2.2, 2, 30, 30, 2.1, 7] -let s = new dfd.Series(data) - -s.loc([`1:`]).print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═════╗ -║ 1 │ 34 ║ -╟───┼─────╢ -║ 2 │ 2.2 ║ -╟───┼─────╢ -║ 3 │ 2 ║ -╟───┼─────╢ -║ 4 │ 30 ║ -╟───┼─────╢ -║ 5 │ 30 ║ -╟───┼─────╢ -║ 6 │ 2.1 ║ -╟───┼─────╢ -║ 7 │ 7 ║ -╚═══╧═════╝ - -``` -{% endtab %} -{% endtabs %} - -### Slice Series by boolean condition - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let s = new dfd.Series([12, 34, 2.2, 2, 30, 30, 2.1, 7]) -s.loc(s.gt(20)).print() -``` -{% endtab %} -{% endtabs %} - -``` -╔═══╤════╗ -║ 1 │ 34 ║ -╟───┼────╢ -║ 4 │ 30 ║ -╟───┼────╢ -║ 5 │ 30 ║ -╚═══╧════╝ -``` diff --git a/api-reference-v1-stable/series/series.lt.md b/api-reference-v1-stable/series/series.lt.md deleted file mode 100644 index 7af18bc..0000000 --- a/api-reference-v1-stable/series/series.lt.md +++ /dev/null @@ -1,96 +0,0 @@ ---- -description: Check if all values in a Series are less than a value. ---- - -# Series.lt - -> danfo.Series.lt(other) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L847)] - -| Parameters | Type | Description | Default | -| ---------- | ----------------------- | ------------------- | ------- | -| other | Series, Array or number | value(s) to compare | | - -**Returns**: Series (boolean element) - -**Example** - -Check if all the values in a series are less than a value - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [10, 45, 56, 25, 23, 20, 10] -let sf1 = new dfd.Series(data1) - -sf1.lt(20).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ false ║ -╟───┼──────────────────────╢ -║ 1 │ true ║ -╟───┼──────────────────────╢ -║ 2 │ true ║ -╟───┼──────────────────────╢ -║ 3 │ true ║ -╟───┼──────────────────────╢ -║ 4 │ true ║ -╟───┼──────────────────────╢ -║ 5 │ false ║ -╟───┼──────────────────────╢ -║ 6 │ false ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -check if all the values in a series are less than values in another series. - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [10, 45, 56, 25, 23, 20, 10] -let data2 = [10, 450, 56, 5, 25, 2, 0] -let sf1 = new dfd.Series(data1) -let sf2 = new dfd.Series(data2) - -sf1.lt(sf2).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ false ║ -╟───┼──────────────────────╢ -║ 1 │ true ║ -╟───┼──────────────────────╢ -║ 2 │ false ║ -╟───┼──────────────────────╢ -║ 3 │ false ║ -╟───┼──────────────────────╢ -║ 4 │ true ║ -╟───┼──────────────────────╢ -║ 5 │ false ║ -╟───┼──────────────────────╢ -║ 6 │ false ║ -╚═══╧══════════════════════╝ - -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.map.md b/api-reference-v1-stable/series/series.map.md deleted file mode 100644 index 0e0850a..0000000 --- a/api-reference-v1-stable/series/series.map.md +++ /dev/null @@ -1,92 +0,0 @@ ---- -description: Map the value of a series to a function or Object ---- - -# Series.map - -> danfo.series.**map**(callable) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L685)] - -| Parameter | Type | Description | Default | -| --------- | ------------------ | ---------------------------------------------------------------------------------------------- | ------------------------------------- | -| callable | Function or Object | A function or object({}) | | -| options | Object | inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false |

{

inplace: false

}

| - -**Example** - -Mapping the element in a Series words in an Object - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let sf = new dfd.Series([1, 2, 3, 4]) -let map = { 1: "ok", 2: "okie", 3: "frit", 4: "gop" } -sf.map(map).print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ ok ║ -╟───┼──────────────────────╢ -║ 1 │ okie ║ -╟───┼──────────────────────╢ -║ 2 │ frit ║ -╟───┼──────────────────────╢ -║ 3 │ gop ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -Mapping values in a Series to a representation using functions. - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let sf = new dfd.Series([1,2,3,4]) - -sf.map((x)=>{ - return `I have ${x} cat(s)` -}).print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ I have 1 cat(s) ║ -╟───┼──────────────────────╢ -║ 1 │ I have 2 cat(s) ║ -╟───┼──────────────────────╢ -║ 2 │ I have 3 cat(s) ║ -╟───┼──────────────────────╢ -║ 3 │ I have 4 cat(s) ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.max.md b/api-reference-v1-stable/series/series.max.md deleted file mode 100644 index 4f7193a..0000000 --- a/api-reference-v1-stable/series/series.max.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -description: Obtain the maximum value in a Series ---- - -# Series.max - -> danfo.Series.max() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L317)] - -**Parameter:** None - -**Return:** Number - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [20, 30, 1, 2, 4, 57, 89, 0, 4] -let sf1 = new dfd.Series(data1) - -console.log(sf1.max()) -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -89 -``` -{% endtab %} -{% endtabs %} - -**** diff --git a/api-reference-v1-stable/series/series.maximum.md b/api-reference-v1-stable/series/series.maximum.md deleted file mode 100644 index afc5a48..0000000 --- a/api-reference-v1-stable/series/series.maximum.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -description: Obtain the maximum number between two series ---- - -# Series.maximum - -> danfo.Series.maximum\(other\) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L363)\] - -| Parameters | Type | Description | Default | -| :--- | :--- | :--- | :--- | -| other | Series | series to match | | - -**Return:** {Series} - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [30, 40, 3, 5] -let data2 = [10, 41, 2, 0] -let sf1 = new dfd.Series(data1) -let sf2 = new dfd.Series(data2) -sf1.maximum(sf2).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="output" %} -```text -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 30 ║ -╟───┼──────────────────────╢ -║ 1 │ 41 ║ -╟───┼──────────────────────╢ -║ 2 │ 3 ║ -╟───┼──────────────────────╢ -║ 3 │ 5 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - - - diff --git a/api-reference-v1-stable/series/series.mean.md b/api-reference-v1-stable/series/series.mean.md deleted file mode 100644 index 17d97e6..0000000 --- a/api-reference-v1-stable/series/series.mean.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -description: Obtain the mean of a series ---- - -# Series.mean - -> danfo.Series.mean() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L253)] - -**Parameter:** None - -**Return:** Number - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [20, 30, 1, 2, 4, 57, 89, 0, 4] -let sf1 = new dfd.Series(data1) - -console.log(sf1.mean()) -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -23.000001907348633 -``` -{% endtab %} -{% endtabs %} - -**** diff --git a/api-reference-v1-stable/series/series.median.md b/api-reference-v1-stable/series/series.median.md deleted file mode 100644 index d1cde75..0000000 --- a/api-reference-v1-stable/series/series.median.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -description: Obtain the median of a series ---- - -# Series.median - -> danfo.Series.median() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L274)] - -**Parameter:** None - -**Return:** Number - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [20, 30, 1, 2, 4, 57, 89, 0, 4] -let sf1 = new dfd.Series(data1) - -console.log(sf1.median()) -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -4 -``` -{% endtab %} -{% endtabs %} - -**** diff --git a/api-reference-v1-stable/series/series.min.md b/api-reference-v1-stable/series/series.min.md deleted file mode 100644 index 6e11a67..0000000 --- a/api-reference-v1-stable/series/series.min.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -description: Obtain the minimum value in a series ---- - -# Series.min - -> danfo.Series.min() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L303)] - -**Parameter:** None - -**Return:** Number - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [20, 30, 1, 2, 4, 57, 89, 0, 4] -let sf1 = new dfd.Series(data1) - -console.log(sf1.min()) -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -0 -``` -{% endtab %} -{% endtabs %} - -**** diff --git a/api-reference-v1-stable/series/series.minimum.md b/api-reference-v1-stable/series/series.minimum.md deleted file mode 100644 index a06ba69..0000000 --- a/api-reference-v1-stable/series/series.minimum.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -description: Obtain the minimum value between two series (element wise) ---- - -# Series.minimum - -> danfo.Series.minimum\(other\) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L383)\] - -| Parameters | Type | Description | Default | -| :--- | :--- | :--- | :--- | -| other | Series | series to match | | - -**Return:** {Series} - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [30, 40, 3, 5] -let data2 = [10, 41, 2, 0] -let sf1 = new dfd.Series(data1) -let sf2 = new dfd.Series(data2) -sf1.minimum(sf2).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="output" %} -```text -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 10 ║ -╟───┼──────────────────────╢ -║ 1 │ 40 ║ -╟───┼──────────────────────╢ -║ 2 │ 2 ║ -╟───┼──────────────────────╢ -║ 3 │ 0 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/series/series.mod.md b/api-reference-v1-stable/series/series.mod.md deleted file mode 100644 index fdf0555..0000000 --- a/api-reference-v1-stable/series/series.mod.md +++ /dev/null @@ -1,85 +0,0 @@ ---- -description: Return Modulo of series and other, element-wise (binary operator mod). ---- - -# Series.mod - -> danfo.Series.mod(other, options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L235)] - -| Parameters | Type | Description | Default | -| ---------- | ------------------ | ---------------------------------------------------------------------------------------------- | ------------------------------------- | -| other | Series\|int\|float | values | | -| options | Object | inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false |

{

inplace: false

}

| - -**Return:** Series - -**Example** - -Modulus with values of another series - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [2, 30, 4, 5] -let data2 = [1.1, 2.2, 3.3, 2.4] -let sf1 = new dfd.Series(data1) -let sf2 = new dfd.Series(data2) -sf1.mod(sf2).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 0.8999999761581421 ║ -╟───┼──────────────────────╢ -║ 1 │ 1.3999993801116943 ║ -╟───┼──────────────────────╢ -║ 2 │ 0.7000000476837158 ║ -╟───┼──────────────────────╢ -║ 3 │ 0.19999980926513672 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -Modulo with a value - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [1, 2, 3, 4, 5] -let sf1 = new dfd.Series(data1) - -sf1.mod(2).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 1 ║ -╟───┼──────────────────────╢ -║ 1 │ 0 ║ -╟───┼──────────────────────╢ -║ 2 │ 1 ║ -╟───┼──────────────────────╢ -║ 3 │ 0 ║ -╟───┼──────────────────────╢ -║ 4 │ 1 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.mode.md b/api-reference-v1-stable/series/series.mode.md deleted file mode 100644 index 6077686..0000000 --- a/api-reference-v1-stable/series/series.mode.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -description: Obtain the center value in a series ---- - -# Series.mode - -> danfo.Series.min() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L303)] - -**Parameter:** None - -**Return:** Number - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [20, 30, 1, 2, 4, 57, 89, 0, 4] -let sf1 = new dfd.Series(data1) - -console.log(sf1.mode()) -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -[ 4 ] -``` -{% endtab %} -{% endtabs %} - -**** diff --git a/api-reference-v1-stable/series/series.mul.md b/api-reference-v1-stable/series/series.mul.md deleted file mode 100644 index d5d33de..0000000 --- a/api-reference-v1-stable/series/series.mul.md +++ /dev/null @@ -1,86 +0,0 @@ ---- -description: Return Multiplication of series and other, element-wise (binary operator mul). ---- - -# Series.mul - -> danfo.Series.mul(other, options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L168)] - -| Parameters | Type | Description | Default | -| ---------- | ------------- | ---------------------------------------------------------------------------------------------- | ------------------------------------- | -| other | Series\|int\| | values | | -| options | Object | inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false |

{

inplace: false

}

| - -**Return:** Series - -**Example** - -multiplication with values of another series - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [30, 40, 3, 5] -let data2 = [1, 2, 3, 4] -let sf1 = new dfd.Series(data1) -let sf2 = new dfd.Series(data2) -sf1.mul(sf2).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 30 ║ -╟───┼──────────────────────╢ -║ 1 │ 80 ║ -╟───┼──────────────────────╢ -║ 2 │ 9 ║ -╟───┼──────────────────────╢ -║ 3 │ 20 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -multiply with a value - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [1, 2, 3, 4, 5] -let sf1 = new dfd.Series(data1) - -sf1.mul(2).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 2 ║ -╟───┼──────────────────────╢ -║ 1 │ 4 ║ -╟───┼──────────────────────╢ -║ 2 │ 6 ║ -╟───┼──────────────────────╢ -║ 3 │ 8 ║ -╟───┼──────────────────────╢ -║ 4 │ 10 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/series/series.ndim.md b/api-reference-v1-stable/series/series.ndim.md deleted file mode 100644 index 8623e80..0000000 --- a/api-reference-v1-stable/series/series.ndim.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -description: Obtain the dimension of a series ---- - -# Series.ndim - -> danfo.Series.ndim \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/generic.js#L209)] - -**Parameters:** None - -**Returns:** int - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [30.21091, 40.190901, 3.564, 5.0212] -let sf1 = new dfd.Series(data1) - -console.log(sf1.ndim) -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -1 -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.ne.md b/api-reference-v1-stable/series/series.ne.md deleted file mode 100644 index 16cf1dc..0000000 --- a/api-reference-v1-stable/series/series.ne.md +++ /dev/null @@ -1,95 +0,0 @@ ---- -description: Check if all values in a series is not equal to a value(s) ---- - -# Series.ne - -> danfo.Series.ne(other) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L883)] - -| Parameters | Type | Description | Default | -| ---------- | ----------------------- | ----------------- | ------- | -| other | Series, Array or number | value to compare | | - -**Returns**: Series (Boolean element) - -**Example** - -Compare all the values in a series to that in another series - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [10, 45, 56, 25, 23, 20, 10] -let data2 = [10, 450, 56, 5, 25, 2, 0] -let sf1 = new dfd.Series(data1) -let sf2 = new dfd.Series(data2) - -sf1.ne(sf2).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ false ║ -╟───┼──────────────────────╢ -║ 1 │ true ║ -╟───┼──────────────────────╢ -║ 2 │ false ║ -╟───┼──────────────────────╢ -║ 3 │ true ║ -╟───┼──────────────────────╢ -║ 4 │ true ║ -╟───┼──────────────────────╢ -║ 5 │ true ║ -╟───┼──────────────────────╢ -║ 6 │ true ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -Compare all the values in a Series to a value. - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [10, 45, 56, 25, 23, 20, 10] -let sf1 = new dfd.Series(data1) - -sf1.ne(10).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ false ║ -╟───┼──────────────────────╢ -║ 1 │ true ║ -╟───┼──────────────────────╢ -║ 2 │ true ║ -╟───┼──────────────────────╢ -║ 3 │ true ║ -╟───┼──────────────────────╢ -║ 4 │ true ║ -╟───┼──────────────────────╢ -║ 5 │ true ║ -╟───┼──────────────────────╢ -║ 6 │ false ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.nunique.md b/api-reference-v1-stable/series/series.nunique.md deleted file mode 100644 index 092a2eb..0000000 --- a/api-reference-v1-stable/series/series.nunique.md +++ /dev/null @@ -1,34 +0,0 @@ ---- -description: Returns the number of unique values in a series ---- - -# Series.nunique - -> danfo.Series.**nunique**() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L750)] - -**Parameters**: None - -**Returns:** int - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [1, 2, 3, 4, 5, 6, 7, 8, 1, 1, 22, 8, 5, 5, 5] -let sf = new dfd.Series(data1) - -console.log(sf.nunique()) -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Ouptut" %} -``` -9 -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.or.md b/api-reference-v1-stable/series/series.or.md deleted file mode 100644 index 948c61d..0000000 --- a/api-reference-v1-stable/series/series.or.md +++ /dev/null @@ -1,132 +0,0 @@ ---- -description: >- - Returns the logical OR between Series and other. Supports element wise - operations and broadcasting. ---- - -# Series.or - -> danfo.Series.**or**\(other\) \[[source](https://github.com/opensource9ja/danfojs/blob/e25010c26d9c423412613d820015a48ad03d5c6d/danfojs-node/src/core/series.js#L1243)\] - -| Parameters | Type | Description | Default | -| :--- | :--- | :--- | :--- | -| other | Series, Scalar, Array of Scalars | Data to compare with | | - - **Return:** Series - -### **Logical OR between two Series object** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [false, false, false, true, false, false, true]; -let data2 = [false, false, false, false, false, false, true]; - -let sf = new dfd.Series(data1); -let sf2 = new dfd.Series(data2); -let res = sf.or(sf2) -res.print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```text -╔═══╤═══════╗ -║ 0 │ false ║ -╟───┼───────╢ -║ 1 │ false ║ -╟───┼───────╢ -║ 2 │ false ║ -╟───┼───────╢ -║ 3 │ true ║ -╟───┼───────╢ -║ 4 │ false ║ -╟───┼───────╢ -║ 5 │ false ║ -╟───┼───────╢ -║ 6 │ true ║ -╚═══╧═══════╝ -``` -{% endtab %} -{% endtabs %} - -### **Logical OR between Series and Array of the same length** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [false, false, false, true, false, false, true]; -let data2 = [false, false, false, false, false, false, true]; - -let sf = new dfd.Series(data1); -let res = sf.or(data2) -res.print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```text -╔═══╤═══════╗ -║ 0 │ false ║ -╟───┼───────╢ -║ 1 │ false ║ -╟───┼───────╢ -║ 2 │ false ║ -╟───┼───────╢ -║ 3 │ true ║ -╟───┼───────╢ -║ 4 │ false ║ -╟───┼───────╢ -║ 5 │ false ║ -╟───┼───────╢ -║ 6 │ true ║ -╚═══╧═══════╝ -``` -{% endtab %} -{% endtabs %} - -### **Logical OR between a Series and single value with broadcasting** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") -let data1 = [false, false, false, true, false, false, true]; - -let sf = new dfd.Series(data1); -let res = sf.or(false) -res.print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```text -╔═══╤═══════╗ -║ 0 │ false ║ -╟───┼───────╢ -║ 1 │ false ║ -╟───┼───────╢ -║ 2 │ false ║ -╟───┼───────╢ -║ 3 │ true ║ -╟───┼───────╢ -║ 4 │ false ║ -╟───┼───────╢ -║ 5 │ false ║ -╟───┼───────╢ -║ 6 │ true ║ -╚═══╧═══════╝ -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/series/series.pow.md b/api-reference-v1-stable/series/series.pow.md deleted file mode 100644 index 2fbe542..0000000 --- a/api-reference-v1-stable/series/series.pow.md +++ /dev/null @@ -1,87 +0,0 @@ ---- -description: >- - Return Exponential power of series and other, element-wise (binary operator - pow). ---- - -# Series.pow - -> danfo.Series.pow(other, options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L216)] - -| Parameters | Type | Description | Default | -| ---------- | ------------- | ---------------------------------------------------------------------------------------------- | ------------------------------------- | -| other | Series\|int\| | values | | -| options | Object | inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false |

{

inplace: false

}

| - -**Return:** Series - -**Example** - -Exponential power with values of another series - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [2, 3, 4, 5] -let data2 = [1, 2, 3, 0] -let sf1 = new dfd.Series(data1) -let sf2 = new dfd.Series(data2) -sf1.pow(sf2).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 2 ║ -╟───┼──────────────────────╢ -║ 1 │ 9 ║ -╟───┼──────────────────────╢ -║ 2 │ 64 ║ -╟───┼──────────────────────╢ -║ 3 │ 1 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -Exponential value with a value - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [1, 2, 3, 4, 5] -let sf1 = new dfd.Series(data1) - -sf1.pow(2).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 1 ║ -╟───┼──────────────────────╢ -║ 1 │ 4 ║ -╟───┼──────────────────────╢ -║ 2 │ 9 ║ -╟───┼──────────────────────╢ -║ 3 │ 16 ║ -╟───┼──────────────────────╢ -║ 4 │ 25 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.replace.md b/api-reference-v1-stable/series/series.replace.md deleted file mode 100644 index 8a1f48b..0000000 --- a/api-reference-v1-stable/series/series.replace.md +++ /dev/null @@ -1,89 +0,0 @@ ---- -description: Replace values given in replace param with value ---- - -# Series.replace - -> danfo.Series.**replace**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L892)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- | -| options | Object |

oldValue: The value you want to replace

newValue: The new value you want to replace the old value with

inplace: Boolean indicating whether to perform the operation inplace or not

|

{

inplace: false

}

| - -**Returns**: Series - -**Examples** - -### Replace a value in a series and return a new series - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [10, 45, 56, 25, 23, 20, 10] -let sf = new dfd.Series(data1) -let sf_rep = sf.replace({ oldValue: 10, newValue: -50 }) - -sf_rep.print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═════╗ -║ 0 │ -50 ║ -╟───┼─────╢ -║ 1 │ 45 ║ -╟───┼─────╢ -║ 2 │ 56 ║ -╟───┼─────╢ -║ 3 │ 25 ║ -╟───┼─────╢ -║ 4 │ 23 ║ -╟───┼─────╢ -║ 5 │ 20 ║ -╟───┼─────╢ -║ 6 │ -50 ║ -╚═══╧═════╝ - -``` -{% endtab %} -{% endtabs %} - -### Replace a value in-place - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [10, 45, 56, 25, 23, 20, 10] -let sf = new dfd.Series(data1) -sf.replace({ oldValue: 10, newValue: -50, inplace: true}) - -sf.print() -``` -{% endtab %} -{% endtabs %} - -``` -╔═══╤═════╗ -║ 0 │ -50 ║ -╟───┼─────╢ -║ 1 │ 45 ║ -╟───┼─────╢ -║ 2 │ 56 ║ -╟───┼─────╢ -║ 3 │ 25 ║ -╟───┼─────╢ -║ 4 │ 23 ║ -╟───┼─────╢ -║ 5 │ 20 ║ -╟───┼─────╢ -║ 6 │ -50 ║ -╚═══╧═════╝ - -``` diff --git a/api-reference-v1-stable/series/series.reset_index.md b/api-reference-v1-stable/series/series.reset_index.md deleted file mode 100644 index c51497a..0000000 --- a/api-reference-v1-stable/series/series.reset_index.md +++ /dev/null @@ -1,113 +0,0 @@ ---- -description: Reset the index of a series. ---- - -# Series.reset\_index - -> danfo.series.reset\_index(options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L614)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | --------------------------------------------------------------------------------------------------- | ---------------- | -| options | Object | **inplace:** Boolean indicating whether to perform the operation inplace or not. Defaults to false | { inplace:false} | - -**Returns :** Series - -`reset_index` is useful when the index needs to be treated as a column, or when the index is meaningless and needs to be reset to default, before another operation. - -### **Reset index to default values** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") -let data = [20, 30, 40] -let sf = new dfd.Series(data, { index: ["a", "b", "c"] }) -sf.print() - -let sf_reset = sf.reset_index() -sf_reset.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤════╗ -║ a │ 20 ║ -╟───┼────╢ -║ b │ 30 ║ -╟───┼────╢ -║ c │ 40 ║ -╚═══╧════╝ - -╔═══╤════╗ -║ 0 │ 20 ║ -╟───┼────╢ -║ 1 │ 30 ║ -╟───┼────╢ -║ 2 │ 40 ║ -╚═══╧════╝ -``` -{% endtab %} -{% endtabs %} - -### Reset index to new values in-place - -{% tabs %} -{% tab title="Node" %} -```javascript -let data = [1, 2, 3, 4, 5, 6] -let sf = new dfd.Series(data, { index: ['a', 'b', 'c', 'd', 'e', 'f'] }) -sf.print() - -sf.reset_index({ inplace: true }) -sf.print() - -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══╗ -║ a │ 1 ║ -╟───┼───╢ -║ b │ 2 ║ -╟───┼───╢ -║ c │ 3 ║ -╟───┼───╢ -║ d │ 4 ║ -╟───┼───╢ -║ e │ 5 ║ -╟───┼───╢ -║ f │ 6 ║ -╚═══╧═══╝ - -╔═══╤═══╗ -║ 0 │ 1 ║ -╟───┼───╢ -║ 1 │ 2 ║ -╟───┼───╢ -║ 2 │ 3 ║ -╟───┼───╢ -║ 3 │ 4 ║ -╟───┼───╢ -║ 4 │ 5 ║ -╟───┼───╢ -║ 5 │ 6 ║ -╚═══╧═══╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.round.md b/api-reference-v1-stable/series/series.round.md deleted file mode 100644 index b6f0d82..0000000 --- a/api-reference-v1-stable/series/series.round.md +++ /dev/null @@ -1,48 +0,0 @@ ---- -description: round off floating values in series ---- - -# Series.round - -> danfo.Series.round(dp, options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L404)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ---------------------------------------------------------------------------------------------- | ------------------------------------- | -| dp | int | decimal place to round off to | | -| options | Object | inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false |

{

inplace: false

}

| - -**Returns:** Series - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [30.21091, 40.190901, 3.564, 5.0212] -let sf1 = new dfd.Series(data1) - -sf1.round(2).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 30.21 ║ -╟───┼──────────────────────╢ -║ 1 │ 40.19 ║ -╟───┼──────────────────────╢ -║ 2 │ 3.56 ║ -╟───┼──────────────────────╢ -║ 3 │ 5.02 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/series/series.sample.md b/api-reference-v1-stable/series/series.sample.md deleted file mode 100644 index a28298d..0000000 --- a/api-reference-v1-stable/series/series.sample.md +++ /dev/null @@ -1,65 +0,0 @@ ---- -description: Return a random sample of items from an axis of object. ---- - -# Series.sample - -> danfo.Series.sample(num) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L98)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------ | -| num | Int | The number of rows to return. | | -| options | Object | **seed**: An integer specifying the random seed that will be used to create the distribution. Ensures reproducibility of generated samples. |

{

seed: 1

}

| - -**Returns:** - - **** return **{Promies} resolves to Series** - -**Example** - -```javascript -const dfd = require("danfojs-node") - -async function load_data() { - let data1 = [1, 2, 3, 4, 5, 620, 30, 40, 39, 89, 78]; - let sf1 = new dfd.Series(data1); - let sample = await sf1.sample(5) - sample.print() - -} -load_data() -``` - -{% tabs %} -{% tab title="Output" %} -```javascript -╔═══╤════╗ -║ 2 │ 3 ║ -╟───┼────╢ -║ 4 │ 5 ║ -╟───┼────╢ -║ 0 │ 1 ║ -╟───┼────╢ -║ 7 │ 40 ║ -╟───┼────╢ -║ 6 │ 30 ║ -╚═══╧════╝ -``` -{% endtab %} -{% endtabs %} - -### Specify a seed when sampling - -```javascript -const dfd = require("danfojs-node") - -async function load_data() { - let data1 = [1, 2, 3, 4, 5, 620, 30, 40, 39, 89, 78]; - let sf1 = new dfd.Series(data1); - let sample = await sf1.sample(5, { seed: 2 }) - sample.print() - -} -load_data() - -``` diff --git a/api-reference-v1-stable/series/series.set_index.md b/api-reference-v1-stable/series/series.set_index.md deleted file mode 100644 index 3de352f..0000000 --- a/api-reference-v1-stable/series/series.set_index.md +++ /dev/null @@ -1,136 +0,0 @@ ---- -description: Assign new Index to Series ---- - -# Series.set\_index - -> danfo.series.**set\_index(**options**)** \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L635)] - -| Parameter | Type | Description | Default | -| --------- | ------ | ---------------------------------------------------------------------------------------------- | ------------------------------------- | -| index | Array | new index values | | -| options | Object | inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false |

{

inplace: false

}

| - -**Returns:** Series - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") -let data = [{ alpha: "A", count: 1 }, { alpha: "B", count: 2 }, { alpha: "C", count: 3 }] -let sf = new dfd.Series(data) -sf.print() - -let sf_new = sf.set_index({ "index": ["one", "two", "three"] }) -sf_new.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═════════════════════════╗ -║ 0 │ {"alpha":"A","count":1} ║ -╟───┼─────────────────────────╢ -║ 1 │ {"alpha":"B","count":2} ║ -╟───┼─────────────────────────╢ -║ 2 │ {"alpha":"C","count":3} ║ -╚═══╧═════════════════════════╝ - -╔═══════╤═════════════════════════╗ -║ one │ {"alpha":"A","count":1} ║ -╟───────┼─────────────────────────╢ -║ two │ {"alpha":"B","count":2} ║ -╟───────┼─────────────────────────╢ -║ three │ {"alpha":"C","count":3} ║ -╚═══════╧═════════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = ["Humans","Life","Meaning","Fact","Truth"] -let sf = new dfd.Series(data) -let sf_new = sf.set_index({ "index": ["H", "L", "M","F","T"] }) -sf_new.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ H │ Humans ║ -╟───┼──────────────────────╢ -║ L │ Life ║ -╟───┼──────────────────────╢ -║ M │ Meaning ║ -╟───┼──────────────────────╢ -║ F │ Fact ║ -╟───┼──────────────────────╢ -║ T │ Truth ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -### Set index in-place - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs") - -let data = [1, 2, 3, 4, 5, 6] -let sf = new dfd.Series(data) -sf.set_index({ index: ["one", "two", "three", "four", "five", "six"], inplace: true }) -sf.print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══════╤═══╗ -║ one │ 1 ║ -╟───────┼───╢ -║ two │ 2 ║ -╟───────┼───╢ -║ three │ 3 ║ -╟───────┼───╢ -║ four │ 4 ║ -╟───────┼───╢ -║ five │ 5 ║ -╟───────┼───╢ -║ six │ 6 ║ -╚═══════╧═══╝ - -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.shape.md b/api-reference-v1-stable/series/series.shape.md deleted file mode 100644 index 9eb5031..0000000 --- a/api-reference-v1-stable/series/series.shape.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -description: Obtain the shape of a Series ---- - -# Series.shape - -> danfo.Series.shape \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/generic.js#L266)\] - -**Parameters**: None - -**Returns**: Array \[int, int\] - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [30.21091, 40.190901, 3.564, 5.0212] -let sf1 = new dfd.Series(data1) - -console.log(sf1.shape) -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```text -[ 4, 1 ] -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/series/series.size.md b/api-reference-v1-stable/series/series.size.md deleted file mode 100644 index 9665b65..0000000 --- a/api-reference-v1-stable/series/series.size.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -description: Obtain the size of a series ---- - -# Series.size - -> danfo.Series.size \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/generic.js#L305)\] - -**Parameters**: None - -**Returns:** int - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [30.21091, 40.190901, 3.564, 5.0212] -let sf1 = new dfd.Series(data1) - -console.log(sf1.size) -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```text -4 -``` -{% endtab %} -{% endtabs %} - - - diff --git a/api-reference-v1-stable/series/series.sort_values.md b/api-reference-v1-stable/series/series.sort_values.md deleted file mode 100644 index 5c7e5fa..0000000 --- a/api-reference-v1-stable/series/series.sort_values.md +++ /dev/null @@ -1,140 +0,0 @@ ---- -description: Sorts a Series in ascending or descending order ---- - -# Series.sort_values - -> danfo.Series.sort_values(options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L511)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- | -| options | Object |

inplace: Boolean indicating whether to perform the operation in-place or not. Defaults to false

ascending: Whether to return sorted values in ascending order or not. Defaults to true

|

{
ascending: true,

inplace: false

}

| - - **Return:** Series - -### Sort values in a Series - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [20, 30, 1, 2, 4, 57, 89, 0, 4] -let sf1 = new dfd.Series(data1) -let sf2 = sf1.sort_values() - -sf2.print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤════╗ -║ 7 │ 0 ║ -╟───┼────╢ -║ 2 │ 1 ║ -╟───┼────╢ -║ 3 │ 2 ║ -╟───┼────╢ -║ 8 │ 4 ║ -╟───┼────╢ -║ 4 │ 4 ║ -╟───┼────╢ -║ 0 │ 20 ║ -╟───┼────╢ -║ 1 │ 30 ║ -╟───┼────╢ -║ 5 │ 57 ║ -╟───┼────╢ -║ 6 │ 89 ║ -╚═══╧════╝ -``` -{% endtab %} -{% endtabs %} - -### Sort Series in-place - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [20, 30, 1, 2, 4, 57, 89, 0, 4] -let sf1 = new dfd.Series(data1) -sf1.sort_values({ inplace: true }) - -sf1.print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤════╗ -║ 7 │ 0 ║ -╟───┼────╢ -║ 2 │ 1 ║ -╟───┼────╢ -║ 3 │ 2 ║ -╟───┼────╢ -║ 8 │ 4 ║ -╟───┼────╢ -║ 4 │ 4 ║ -╟───┼────╢ -║ 0 │ 20 ║ -╟───┼────╢ -║ 1 │ 30 ║ -╟───┼────╢ -║ 5 │ 57 ║ -╟───┼────╢ -║ 6 │ 89 ║ -╚═══╧════╝ - -``` -{% endtab %} -{% endtabs %} - -Sort Series values in descending order - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [20, 30, 1, 2, 4, 57, 89, 0, 4] -let sf1 = new dfd.Series(data1) -sf1.sort_values({ "ascending": false, "inplace": true }) - -sf1.print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤════╗ -║ 6 │ 89 ║ -╟───┼────╢ -║ 5 │ 57 ║ -╟───┼────╢ -║ 1 │ 30 ║ -╟───┼────╢ -║ 0 │ 20 ║ -╟───┼────╢ -║ 4 │ 4 ║ -╟───┼────╢ -║ 8 │ 4 ║ -╟───┼────╢ -║ 3 │ 2 ║ -╟───┼────╢ -║ 2 │ 1 ║ -╟───┼────╢ -║ 7 │ 0 ║ -╚═══╧════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.std.md b/api-reference-v1-stable/series/series.std.md deleted file mode 100644 index aa05018..0000000 --- a/api-reference-v1-stable/series/series.std.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -description: Obtain the standard deviation for a series ---- - -# Series.std - -> danfo.Series.std() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L422)] - -**Parameter:** None - -**Return:** Number - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [20, 30, 1, 2, 4, 57, 89, 0, 4] -let sf1 = new dfd.Series(data1) - -console.log(sf1.std()) -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -31.11671576500322 -``` -{% endtab %} -{% endtabs %} - - **** - diff --git a/api-reference-v1-stable/series/series.str.capitalize.md b/api-reference-v1-stable/series/series.str.capitalize.md deleted file mode 100644 index aea9e91..0000000 --- a/api-reference-v1-stable/series/series.str.capitalize.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -description: Capitalize the first character of each string ---- - -# Series.str.capitalize - -> danfo.Series.str.**capitalize**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/strings.js#L46)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | --------------------------------------------------------------- | ------------------------------------------------------ | -| options | Object | **inplace**: Whether to perform the operation in-place or not. |

{

inplace: false

}

| - -**Returns**: Series (String element) - -**Example** - -Convert the first character of a string to capital letter - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = ['lower boy', 'capitals', 'sentence', 'swApCaSe'] -let sf = new dfd.Series(data) -sf.str.capitalize().print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ Lower boy ║ -╟───┼──────────────────────╢ -║ 1 │ Capitals ║ -╟───┼──────────────────────╢ -║ 2 │ Sentence ║ -╟───┼──────────────────────╢ -║ 3 │ Swapcase ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.str.charat.md b/api-reference-v1-stable/series/series.str.charat.md deleted file mode 100644 index 931bb48..0000000 --- a/api-reference-v1-stable/series/series.str.charat.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -description: Obtain the character at the specified index (position) ---- - -# Series.str.charAt - -> danfo.Series.str.**charAt**(index) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/strings.js#L64)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | --------------------------------------------------------------- | ------------------------------------------------------ | -| index | int | the index at which to obtain the character | 0 | -| options | Object | **inplace**: Whether to perform the operation in-place or not. |

{

inplace: false

}

| - -**Returns**: Series (Character element) - -**Example** - -Obtain the character at index 2 of all string elements in the series. - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = ['lower boy', 'CAPITALS', 'sentence', 'SwApCaSe'] -let sf = new dfd.Series(data) -sf.str.charAt(2).print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ w ║ -╟───┼──────────────────────╢ -║ 1 │ P ║ -╟───┼──────────────────────╢ -║ 2 │ n ║ -╟───┼──────────────────────╢ -║ 3 │ A ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.str.concat.md b/api-reference-v1-stable/series/series.str.concat.md deleted file mode 100644 index e3abe54..0000000 --- a/api-reference-v1-stable/series/series.str.concat.md +++ /dev/null @@ -1,165 +0,0 @@ ---- -description: Joins two or more strings/arrays ---- - -# Series.str.concat - -> danfo.Series.str.**concat**(other, position, options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/strings.js#L80)] - -| Parameters | Type | Description | Default | -| ---------- | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------ | -| other | string or Array | string or list of strings to add to each string element of the series | "" | -| position | Int | The position to add the **other** (string or array) is either 0 or 1. 0 is to add the other at the beginning of each of the string element, and 1 is to add to the end of the string element | 1 | -| options | Object | **inplace**: Whether to perform the operation in-place or not. |

{

inplace: false

}

| - -**Returns:** Series (String element) - -**Examples** - -Add the strings from an Array to the start of each of the String element in Series - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = ['lower boy', 'CAPITALS', 'sentence', 'SwApCaSe'] -let data2 = ['XX', 'YY', 'BB', '01'] -let sf = new dfd.Series(data) -sf.str.concat(data2,0).print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ XXlower boy ║ -╟───┼──────────────────────╢ -║ 1 │ YYCAPITALS ║ -╟───┼──────────────────────╢ -║ 2 │ BBsentence ║ -╟───┼──────────────────────╢ -║ 3 │ 01SwApCaSe ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -Add the strings from an Array to the end of each of the String element in Series - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = ['lower boy', 'CAPITALS', 'sentence', 'SwApCaSe'] -let data2 = ['XX', 'YY', 'BB', '01'] -let sf = new dfd.Series(data) -sf.str.concat(data2,1).print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ lower boyXX ║ -╟───┼──────────────────────╢ -║ 1 │ CAPITALSYY ║ -╟───┼──────────────────────╢ -║ 2 │ sentenceBB ║ -╟───┼──────────────────────╢ -║ 3 │ SwApCaSe01 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -Add a string to the start of each string element in a Series - -{% tabs %} -{% tab title="Output" %} -```javascript -const dfd = require("danfojs-node") - -let data = ['lower boy', 'CAPITALS', 'sentence', 'SwApCaSe'] -let data2 = ['XX', 'YY', 'BB', '01'] -let sf = new dfd.Series(data) -sf.str.concat("pre",0).print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ prelower boy ║ -╟───┼──────────────────────╢ -║ 1 │ preCAPITALS ║ -╟───┼──────────────────────╢ -║ 2 │ presentence ║ -╟───┼──────────────────────╢ -║ 3 │ preSwApCaSe ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -Add a string to the end of each string element in a series - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = ['lower boy', 'CAPITALS', 'sentence', 'SwApCaSe'] -let data2 = ['XX', 'YY', 'BB', '01'] -let sf = new dfd.Series(data) -sf.str.concat("post",1).print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ lower boypost ║ -╟───┼──────────────────────╢ -║ 1 │ CAPITALSpost ║ -╟───┼──────────────────────╢ -║ 2 │ sentencepost ║ -╟───┼──────────────────────╢ -║ 3 │ SwApCaSepost ║ -╚═══╧══════════════════════╝ -``` diff --git a/api-reference-v1-stable/series/series.str.endswith.md b/api-reference-v1-stable/series/series.str.endswith.md deleted file mode 100644 index 2fb44cc..0000000 --- a/api-reference-v1-stable/series/series.str.endswith.md +++ /dev/null @@ -1,51 +0,0 @@ ---- -description: Checks whether a string ends with specified characters ---- - -# Series.str.endsWith - -> danfo.Series.str.**endsWith**(str, options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/strings.js#L133)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | --------------------------------------------------------------- | ------------------------------------------------------ | -| str | string | the character(s) to check | "" | -| options | Object | **inplace**: Whether to perform the operation in-place or not. |

{

inplace: false

}

| - -**Returns**: Series (Boolean element) - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = ['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe'] -let sf = new dfd.Series(data) -sf.str.endsWith("e").print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ false ║ -╟───┼──────────────────────╢ -║ 1 │ false ║ -╟───┼──────────────────────╢ -║ 2 │ true ║ -╟───┼──────────────────────╢ -║ 3 │ true ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.str.includes.md b/api-reference-v1-stable/series/series.str.includes.md deleted file mode 100644 index 8918773..0000000 --- a/api-reference-v1-stable/series/series.str.includes.md +++ /dev/null @@ -1,51 +0,0 @@ ---- -description: Checks whether a string contains the specified string/characters ---- - -# Series.str.includes - -> danfo.Series.str.includes(str, options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/strings.js#L147)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | --------------------------------------------------------------- | ------------------------------------------------------ | -| str | string | the character(s) to check | "" | -| options | Object | **inplace**: Whether to perform the operation in-place or not. |

{

inplace: false

}

| - -**Returns**: Series (boolean element) - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = ['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe'] -let sf = new dfd.Series(data) -sf.str.includes("C").print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ false ║ -╟───┼──────────────────────╢ -║ 1 │ true ║ -╟───┼──────────────────────╢ -║ 2 │ false ║ -╟───┼──────────────────────╢ -║ 3 │ true ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.str.indexof.md b/api-reference-v1-stable/series/series.str.indexof.md deleted file mode 100644 index 1d9e64f..0000000 --- a/api-reference-v1-stable/series/series.str.indexof.md +++ /dev/null @@ -1,51 +0,0 @@ ---- -description: the position of the first found occurrence of a specified value in a string ---- - -# Series.str.indexOf - -> danfo.Series.str.indexOf(str, options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/strings.js#L161)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | --------------------------------------------------------------- | ------------------------------------------------------ | -| str | string | the string to obtain its index | "" | -| options | Object | **inplace**: Whether to perform the operation in-place or not. |

{

inplace: false

}

| - -**Returns:** Series - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = ['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe'] -let sf = new dfd.Series(data) -sf.str.indexOf("C").print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ -1 ║ -╟───┼──────────────────────╢ -║ 1 │ 0 ║ -╟───┼──────────────────────╢ -║ 2 │ -1 ║ -╟───┼──────────────────────╢ -║ 3 │ 4 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.str.join.md b/api-reference-v1-stable/series/series.str.join.md deleted file mode 100644 index 5bb77fe..0000000 --- a/api-reference-v1-stable/series/series.str.join.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -description: Join a new string value to all string elements in a Series. ---- - -# Series.str.join - -> danfo.Series.str.**join**(valToJoin, joinChar, options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/strings.js#L308)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | --------------------------------------------------------------- | ------------------------------------------------------ | -| valToJoin | String | the string value you want to | "" | -| joinChar | String | The delimiter to specify the joining | " " | -| options | Object | **inplace**: Whether to perform the operation in-place or not. |

{

inplace: false

}

| - -**Returns:** - - **** return **Series** - -**Examples** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = ['lower part', 'CAPITALS city', 'this is a sentence', 'SwAp CaSe'] -let sf = new dfd.Series(data) -sf.str.join("new", "_").print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤════════════════════════╗ -║ 0 │ lower part_new ║ -╟───┼────────────────────────╢ -║ 1 │ CAPITALS city_new ║ -╟───┼────────────────────────╢ -║ 2 │ this is a sentence_new ║ -╟───┼────────────────────────╢ -║ 3 │ SwAp CaSe_new ║ -╚═══╧════════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.str.lastindexof.md b/api-reference-v1-stable/series/series.str.lastindexof.md deleted file mode 100644 index 889a1f4..0000000 --- a/api-reference-v1-stable/series/series.str.lastindexof.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -description: >- - Obtain the position of the last found occurrence of a specified value in a - string ---- - -# Series.str.lastIndexOf - -danfo.Series.str.lastIndexOf(str, options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/strings.js#L175)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | --------------------------------------------------------------- | ------------------------------------------------------ | -| str | string | the string to search for | "" | -| options | Object | **inplace**: Whether to perform the operation in-place or not. |

{

inplace: false

}

| - -**Returns**: Series - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = ['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe'] -let sf = new dfd.Series(data) -sf.str.lastIndexOf("r").print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 4 ║ -╟───┼──────────────────────╢ -║ 1 │ -1 ║ -╟───┼──────────────────────╢ -║ 2 │ -1 ║ -╟───┼──────────────────────╢ -║ 3 │ -1 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/series/series.str.len.md b/api-reference-v1-stable/series/series.str.len.md deleted file mode 100644 index 0ef06b2..0000000 --- a/api-reference-v1-stable/series/series.str.len.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -description: Obtain the length of each string element in a Series ---- - -# Series.str.len - -> danfo.Series.str.**len**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/strings.js#L324)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | --------------------------------------------------------------- | ------------------------------------------------------ | -| options | Object | **inplace**: Whether to perform the operation in-place or not. |

{

inplace: false

}

| - -**Examples** - -Returns the length (number of character) of a string, and also return the length (number of elements) of Array - -{% tabs %} -{% tab title="JavaScript" %} -```javascript -const dfd = require("danfojs-node") - -let data = ["dog", 5,"cat","fog","mug","animals"] -let sf = new dfd.Series(data) -sf.str.len().print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤═══╗ -║ 0 │ 3 ║ -╟───┼───╢ -║ 1 │ 1 ║ -╟───┼───╢ -║ 2 │ 3 ║ -╟───┼───╢ -║ 3 │ 3 ║ -╟───┼───╢ -║ 4 │ 3 ║ -╟───┼───╢ -║ 5 │ 7 ║ -╚═══╧═══╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.str.repeat.md b/api-reference-v1-stable/series/series.str.repeat.md deleted file mode 100644 index 703be26..0000000 --- a/api-reference-v1-stable/series/series.str.repeat.md +++ /dev/null @@ -1,51 +0,0 @@ ---- -description: Repeat the the character(s) in a string for a specified number of time ---- - -# Series.str.repeat - -> danfo.Series.str.**repeat**(num, options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/strings.js#L205)] - -| Parameters | Type | Description | Default | -| ---------- | ------- | --------------------------------------------------------------- | ------------------------------------------------------ | -| num | integer | the string to search for | 1 | -| options | Object | **inplace**: Whether to perform the operation in-place or not. |

{

inplace: false

}

| - -**Returns:** Series - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = ['a', 'b', 'c', 'd'] -let sf = new dfd.Series(data) -sf.str.repeat(4).print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ aaaa ║ -╟───┼──────────────────────╢ -║ 1 │ bbbb ║ -╟───┼──────────────────────╢ -║ 2 │ cccc ║ -╟───┼──────────────────────╢ -║ 3 │ dddd ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.str.replace.md b/api-reference-v1-stable/series/series.str.replace.md deleted file mode 100644 index 2b06b1f..0000000 --- a/api-reference-v1-stable/series/series.str.replace.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -description: Replace a word or character(s) in a String element ---- - -# Series.str.replace - -> danfo.Series.str.replace(searchValue, replaceValue, options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/strings.js#L191)] - -| Parameters | Type | Description | Default | -| ------------ | ------ | --------------------------------------------------------------- | ------------------------------------------------------ | -| searchValue | string | String \| Character value to replace. Supports regex. | "" | -| replaceValue | String | string to replace the searched string | "" | -| options | Object | **inplace**: Whether to perform the operation in-place or not. |

{

inplace: false

}

| - -**Returns:** Series - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = ['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe'] -let sf = new dfd.Series(data) -sf.str.replace("A", "XXX").print() -``` -{% endtab %} - -{% tab title="Browse" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ lower ║ -╟───┼──────────────────────╢ -║ 1 │ CXXXPITALS ║ -╟───┼──────────────────────╢ -║ 2 │ this is a sentence ║ -╟───┼──────────────────────╢ -║ 3 │ SwXXXpCaSe ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.str.search.md b/api-reference-v1-stable/series/series.str.search.md deleted file mode 100644 index 99fc428..0000000 --- a/api-reference-v1-stable/series/series.str.search.md +++ /dev/null @@ -1,94 +0,0 @@ ---- -description: Obtain the index position of a searched character in a String ---- - -# Series.str.search - -> danfo.Series.str.**search**(str, options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/strings.js#L220)] - - - -| Parameters | Type | Description | Default | -| ---------- | ------ | --------------------------------------------------------------- | ------------------------------------------------------ | -| str | String | the string to search for | "" | -| options | Object | **inplace**: Whether to perform the operation in-place or not. |

{

inplace: false

}

| - -**Returns:** - - **** return Series: Series of index position - -**Example** - -obtain the index position for a character - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = ['lower part ', ' CAPITALS city', ' this is a sentence', ' SwAp CaSe'] -let sf = new dfd.Series(data) -sf.str.search("S").print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ -1 ║ -╟───┼──────────────────────╢ -║ 1 │ 8 ║ -╟───┼──────────────────────╢ -║ 2 │ -1 ║ -╟───┼──────────────────────╢ -║ 3 │ 2 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -Obtain the index position for a searched word - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = ['lower city ', ' CAPITALS city', ' this is a sentence', ' SwAp CaSe'] -let sf = new dfd.Series(data) -sf.str.search("city").print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 6 ║ -╟───┼──────────────────────╢ -║ 1 │ 10 ║ -╟───┼──────────────────────╢ -║ 2 │ -1 ║ -╟───┼──────────────────────╢ -║ 3 │ -1 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.str.slice.md b/api-reference-v1-stable/series/series.str.slice.md deleted file mode 100644 index cef7a86..0000000 --- a/api-reference-v1-stable/series/series.str.slice.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -description: Obtain the substring of each element in a series ---- - -# Series.str.slice - -> danfo.Series.str.slice(startIndex, endIndex, options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/strings.js#L235)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | --------------------------------------------------------------- | ------------------------------------------------------ | -| startIndex | Number | specify the index to start obtaining the substring | 0 | -| endIndex | Number | specify the index to end the substring | 1 | -| options | Object | **inplace**: Whether to perform the operation in-place or not. |

{

inplace: false

}

| - -**Returns:** - - **** return Series. - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = ['lower part ', ' CAPITALS city', ' this is a sentence', ' SwAp CaSe'] -let sf = new dfd.Series(data) -sf.str.slice(2, 4).print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ we ║ -╟───┼──────────────────────╢ -║ 1 │ AP ║ -╟───┼──────────────────────╢ -║ 2 │ hi ║ -╟───┼──────────────────────╢ -║ 3 │ Sw ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.str.split.md b/api-reference-v1-stable/series/series.str.split.md deleted file mode 100644 index 006795d..0000000 --- a/api-reference-v1-stable/series/series.str.split.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -description: >- - Split string around a given separator/delimiter. The array of strings are then - converted to a string. ---- - -# Series.str.split - -> danfo.Series.str.**split**(splitVal, options) \[[source](https://github.com/opensource9ja/danfojs/blob/e25010c26d9c423412613d820015a48ad03d5c6d/danfojs-node/src/core/strings.js#L553)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | ---------------------------------------------------------- | ------------------------------- | -| splitVal | String | separator or delimiter used to split the string | " " | -| options | Object | **inplace**: Whether to perform operation in-place or not. |

{
inplace: false
}

| - -**Returns** - - return **Series** - -**Examples** - -Split the string value in the Series by space and obtain the Series values - -{% tabs %} -{% tab title="JavaScript" %} -```javascript -const dfd = require("danfojs-node") - -let data = ["king of the music","the lamba queen","I love the hat"] -let sf = new dfd.Series(data) -console.log(sf.str.split().values) -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -**OUTPUT:** `[ 'king,of,the,music', 'the,lamba,queen', 'I,love,the,hat' ]` - -{% tabs %} -{% tab title="JavaScript" %} -```javascript -const dfd = require("danfojs-node") - -let data = ["king_of_the_music","the_lamba_queen","I_love_the_hat"] -let sf = new dfd.Series(data) -sf.str.split("_").print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ king,of,the,music ║ -╟───┼──────────────────────╢ -║ 1 │ the,lamba,queen ║ -╟───┼──────────────────────╢ -║ 2 │ I,love,the,hat ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.str.startswith.md b/api-reference-v1-stable/series/series.str.startswith.md deleted file mode 100644 index 835809e..0000000 --- a/api-reference-v1-stable/series/series.str.startswith.md +++ /dev/null @@ -1,51 +0,0 @@ ---- -description: Test whether a string begins with specified characters ---- - -# Series.str.startsWith - -> danfo.Series.str.**startsWith**(str, options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/strings.js#L119)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | --------------------------------------------------------------- | ------------------------------------------------------ | -| str | string | the character(s) to check | "" | -| options | Object | **inplace**: Whether to perform the operation in-place or not. |

{

inplace: false

}

| - -**Returns:** Series (Boolean element) - -**Examples** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = ['lower', 'CAPITALS', 'this is a sentence', 'SwApCaSe'] -let sf = new dfd.Series(data) -sf.str.startsWith("S").print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ false ║ -╟───┼──────────────────────╢ -║ 1 │ false ║ -╟───┼──────────────────────╢ -║ 2 │ false ║ -╟───┼──────────────────────╢ -║ 3 │ true ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.str.substr.md b/api-reference-v1-stable/series/series.str.substr.md deleted file mode 100644 index 0a391bb..0000000 --- a/api-reference-v1-stable/series/series.str.substr.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -description: >- - Obtain the substring from a String element in a Series, by specifying the - number of string to obtain starting from a specific index. ---- - -# Series.str.substr - -> danfo.Series.str.substr(startIndex, num, options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/strings.js#L265)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | --------------------------------------------------------------- | ------------------------------------------------------ | -| startIndex | Number | specify the index to start obtaining the substring | 0 | -| num | Number | The number of character to obtain starting from the startIndex | 1 | -| options | Object | **inplace**: Whether to perform the operation in-place or not. |

{

inplace: false

}

| - -**Returns:** - - **** return Series - -**Example** - -Obtain substring( containing 4 characters) starting from the third character (2nd index). - -```javascript -const dfd = require("danfojs-node") - -let data = ['lower part ', ' CAPITALS city', ' this is a sentence', ' SwAp CaSe'] -let sf = new dfd.Series(data) -sf.str.substr(2, 4).print() -``` - -{% tabs %} -{% tab title="Output" %} -```javascript -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ wer ║ -╟───┼──────────────────────╢ -║ 1 │ APIT ║ -╟───┼──────────────────────╢ -║ 2 │ his ║ -╟───┼──────────────────────╢ -║ 3 │ SwAp ║ -╚═══╧══════════════════════╝ - -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.str.substring.md b/api-reference-v1-stable/series/series.str.substring.md deleted file mode 100644 index b54702e..0000000 --- a/api-reference-v1-stable/series/series.str.substring.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -description: Obtain the substring of each element in a series ---- - -# Series.str.substring - -> danfo.Series.str.**substring**(startIndex, endIndex, options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/strings.js#L280)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | --------------------------------------------------------------- | ------------------------------------------------------ | -| startIndex | Number | specify the index to start obtaining the substring | 0 | -| endIndex | Number | specify the index to end the substring | 1 | -| options | Object | **inplace**: Whether to perform the operation in-place or not. |

{

inplace: false

}

| - -**Returns** - - **** return **Series** - -**Example** - -Obtain the substring from index 2 to index 4 of the string elements in a Series - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = ['lower part ', ' CAPITALS city', ' this is a sentence', ' SwAp CaSe'] -let sf = new dfd.Series(data) -sf.str.substring(2, 4).print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ we ║ -╟───┼──────────────────────╢ -║ 1 │ AP ║ -╟───┼──────────────────────╢ -║ 2 │ hi ║ -╟───┼──────────────────────╢ -║ 3 │ Sw ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.str.tolowercase.md b/api-reference-v1-stable/series/series.str.tolowercase.md deleted file mode 100644 index 9abe0f5..0000000 --- a/api-reference-v1-stable/series/series.str.tolowercase.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -description: Converts all characters to lower case. ---- - -# Series.str.toLowerCase - -> danfo.Series.str.toLowerCase(options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/strings.js#L20)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | --------------------------------------------------------------- | ------------------------------------------------------ | -| options | Object | **inplace**: Whether to perform the operation in-place or not. |

{

inplace: false

}

| - -**Example** - -Convert all characters in each string element to small letter - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = ['LOWER BOY', 'CAPITALS', 'SENTENCE', 'SWAPCASE'] -let sf = new dfd.Series(data) -sf.str.toLowerCase().print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ lower boy ║ -╟───┼──────────────────────╢ -║ 1 │ capitals ║ -╟───┼──────────────────────╢ -║ 2 │ sentence ║ -╟───┼──────────────────────╢ -║ 3 │ swapcase ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.str.touppercase.md b/api-reference-v1-stable/series/series.str.touppercase.md deleted file mode 100644 index f484390..0000000 --- a/api-reference-v1-stable/series/series.str.touppercase.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -description: Converts all characters to uppercase. ---- - -# Series.str.toUpperCase - -> danfo.Series.str.toUpperCase(options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/strings.js#L33)] - -| Parameters | Type | Description | Default | -| ---------- | ------ | --------------------------------------------------------------- | ------------------------------------------------------ | -| options | Object | **inplace**: Whether to perform the operation in-place or not. |

{

inplace: false

}

| - -**Returns**: Series (String element) - -**Example** - -Convert all characters in each string element to capital letter - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = ['lower boy', 'CAPITALS', 'sentence', 'SwApCaSe'] -let sf = new dfd.Series(data) -sf.str.toUpperCase().print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ LOWER BOY ║ -╟───┼──────────────────────╢ -║ 1 │ CAPITALS ║ -╟───┼──────────────────────╢ -║ 2 │ SENTENCE ║ -╟───┼──────────────────────╢ -║ 3 │ SWAPCASE ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.str.trim.md b/api-reference-v1-stable/series/series.str.trim.md deleted file mode 100644 index 58b7b16..0000000 --- a/api-reference-v1-stable/series/series.str.trim.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -description: Remove leading and trailing Whitespace from a String element ---- - -# Series.str.trim - -> danfo.Series.str.**trim**(options) **\[**[**source**](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/strings.js#L293)**]** - -| Parameters | Type | Description | Default | -| ---------- | ------ | --------------------------------------------------------------- | ------------------------------------------------------ | -| options | Object | **inplace**: Whether to perform the operation in-place or not. |

{

inplace: false

}

| - -**Returns:** - - **** return Series - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data = ['lower part ', ' CAPITALS city', ' this is a sentence', ' SwAp CaSe'] -let sf = new dfd.Series(data) -sf.str.trim().print() -``` -{% endtab %} - -{% tab title="Browser" %} -``` -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ lower part ║ -╟───┼──────────────────────╢ -║ 1 │ CAPITALS city ║ -╟───┼──────────────────────╢ -║ 2 │ this is a sentence ║ -╟───┼──────────────────────╢ -║ 3 │ SwAp CaSe ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.sub.md b/api-reference-v1-stable/series/series.sub.md deleted file mode 100644 index e281d06..0000000 --- a/api-reference-v1-stable/series/series.sub.md +++ /dev/null @@ -1,86 +0,0 @@ ---- -description: Return Subtraction of series and other, element-wise (binary operator sub). ---- - -# Series.sub - -> danfo.Series.sub(other, options) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L148)] - -| Parameters | Type | Description | Default | -| ---------- | ------------- | ---------------------------------------------------------------------------------------------- | ------------------------------------- | -| other | Series\|int\| | values | | -| options | Object | inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false |

{

inplace: false

}

| - -**Return:** Series - -**Example** - -subtract from values of another series - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [30, 40, 3, 5] -let data2 = [1, 2, 3, 4] -let sf1 = new dfd.Series(data1) -let sf2 = new dfd.Series(data2) -sf1.sub(sf2).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 29 ║ -╟───┼──────────────────────╢ -║ 1 │ 38 ║ -╟───┼──────────────────────╢ -║ 2 │ 0 ║ -╟───┼──────────────────────╢ -║ 3 │ 1 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - -subtract from a value - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [1, 2, 3, 4, 5] -let sf1 = new dfd.Series(data1) - -sf1.sub(2).print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ -1 ║ -╟───┼──────────────────────╢ -║ 1 │ 0 ║ -╟───┼──────────────────────╢ -║ 2 │ 1 ║ -╟───┼──────────────────────╢ -║ 3 │ 2 ║ -╟───┼──────────────────────╢ -║ 4 │ 3 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/series/series.sum.md b/api-reference-v1-stable/series/series.sum.md deleted file mode 100644 index fabcba7..0000000 --- a/api-reference-v1-stable/series/series.sum.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -description: Return the sum of the values in a series. ---- - -# Series.sum - -> danfo.Series.sum() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L333)] - -**Parameter:** None - -**Return:** Number - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [20, 30, 1, 2, 4, 57, 89, 0, 4] -let sf1 = new dfd.Series(data1) - -console.log(sf1.sum()) -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -207 -``` -{% endtab %} -{% endtabs %} - -**** diff --git a/api-reference-v1-stable/series/series.tail.md b/api-reference-v1-stable/series/series.tail.md deleted file mode 100644 index 7f986a1..0000000 --- a/api-reference-v1-stable/series/series.tail.md +++ /dev/null @@ -1,49 +0,0 @@ ---- -description: Prints the last n values in a Series ---- - -# Series.tail - -> danfo.Series.tail\(rows\) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L76)\] - -| Parameters | Type | Description | Default | -| :--- | :--- | :--- | :--- | -| rows | Int | number of last n values | 5 | - - **Return:** Series - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [1, 2, 3, 4, 5, 620, 30, 40, 39, 89, 78] -let sf1 = new dfd.Series(data1) - -sf1.tail().print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```text -╔════╤══════════════════════╗ -║ │ 0 ║ -╟────┼──────────────────────╢ -║ 6 │ 30 ║ -╟────┼──────────────────────╢ -║ 7 │ 40 ║ -╟────┼──────────────────────╢ -║ 8 │ 39 ║ -╟────┼──────────────────────╢ -║ 9 │ 89 ║ -╟────┼──────────────────────╢ -║ 10 │ 78 ║ -╚════╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/series/series.tensor.md b/api-reference-v1-stable/series/series.tensor.md deleted file mode 100644 index a5c112c..0000000 --- a/api-reference-v1-stable/series/series.tensor.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -description: Obtain the tensor representation of the values in a Series ---- - -# Series.tensor - -> danfo.Series.tensor \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L45)\] - -**Parameters**: None - -**Returns**: Tensorflow tensor - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [30.21091, 40.190901, 3.564, 5.0212] -let sf1 = new dfd.Series(data1) - -console.log(sf1.tensor) -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```text -Tensor { - kept: false, - isDisposedInternal: false, - shape: [ 4 ], - dtype: 'float32', - size: 4, - strides: [], - dataId: {}, - id: 2, - rankType: '1', - scopeId: 0 -} -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/series/series.unique.md b/api-reference-v1-stable/series/series.unique.md deleted file mode 100644 index c89d187..0000000 --- a/api-reference-v1-stable/series/series.unique.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -description: Obtain the unique value in a Series ---- - -# Series.unique - -> danfo.Series.**unique**\(\) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L736)\] - -**Parameters**: None - -**Returns**: Series - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [1, 2, 3, 4, 5, 6, 7, 8, 1, 1, 22, 8, 5, 5, 5] -let sf = new dfd.Series(data1) - -sf.unique().print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```text -╔═══╤══════════════════════╗ -║ │ 0 ║ -╟───┼──────────────────────╢ -║ 0 │ 1 ║ -╟───┼──────────────────────╢ -║ 1 │ 2 ║ -╟───┼──────────────────────╢ -║ 2 │ 3 ║ -╟───┼──────────────────────╢ -║ 3 │ 4 ║ -╟───┼──────────────────────╢ -║ 4 │ 5 ║ -╟───┼──────────────────────╢ -║ 5 │ 6 ║ -╟───┼──────────────────────╢ -║ 6 │ 7 ║ -╟───┼──────────────────────╢ -║ 7 │ 8 ║ -╟───┼──────────────────────╢ -║ 8 │ 22 ║ -╚═══╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/series/series.value_counts.md b/api-reference-v1-stable/series/series.value_counts.md deleted file mode 100644 index 338064f..0000000 --- a/api-reference-v1-stable/series/series.value_counts.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -description: Count the number of occurrence for each element in a Series ---- - -# Series.value\_counts - -> danfo.Series.value\_counts() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L750)] - -**Parameters:** None - -**Returns:** Series (int element) - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [1, 2, 3, 4, 5, 6, 7, 8, 1, 1, 22, 8, 5, 5, 5] -let sf = new dfd.Series(data1) - -sf.value_counts().print() -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -``` -╔════╤══════════════════════╗ -║ │ 0 ║ -╟────┼──────────────────────╢ -║ 1 │ 3 ║ -╟────┼──────────────────────╢ -║ 2 │ 1 ║ -╟────┼──────────────────────╢ -║ 3 │ 1 ║ -╟────┼──────────────────────╢ -║ 4 │ 1 ║ -╟────┼──────────────────────╢ -║ 5 │ 4 ║ -╟────┼──────────────────────╢ -║ 6 │ 1 ║ -╟────┼──────────────────────╢ -║ 7 │ 1 ║ -╟────┼──────────────────────╢ -║ 8 │ 2 ║ -╟────┼──────────────────────╢ -║ 22 │ 1 ║ -╚════╧══════════════════════╝ -``` -{% endtab %} -{% endtabs %} diff --git a/api-reference-v1-stable/series/series.values.md b/api-reference-v1-stable/series/series.values.md deleted file mode 100644 index 4857487..0000000 --- a/api-reference-v1-stable/series/series.values.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -description: Obtain the values in a series ---- - -# Series.values - -> danfo.Series.values \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/generic.js#L279)\] - -**Parameters:** None - -**Returns**: Array - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [30.21091, 40.190901, 3.564, 5.0212] -let sf1 = new dfd.Series(data1) - -console.log(sf1.values) -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```text -[ 30.21091, 40.190901, 3.564, 5.0212 ] -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference-v1-stable/series/series.var.md b/api-reference-v1-stable/series/series.var.md deleted file mode 100644 index 4fdcbc2..0000000 --- a/api-reference-v1-stable/series/series.var.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -description: Calculate the variance of a Series ---- - -# Series.var - -> danfo.Series.var\(\) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/series.js#L436)\] - -**Parameter:** None - -**Return:** Number - -**Example** - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - -let data1 = [20, 30, 1, 2, 4, 57, 89, 0, 4] -let sf1 = new dfd.Series(data1) - -console.log(sf1.var()) -``` -{% endtab %} -{% endtabs %} - -{% tabs %} -{% tab title="Output" %} -```text -968.25 -``` -{% endtab %} -{% endtabs %} - diff --git a/api-reference/dataframe/creating-a-dataframe.md b/api-reference/dataframe/creating-a-dataframe.md index 2103b9d..b19e5f9 100644 --- a/api-reference/dataframe/creating-a-dataframe.md +++ b/api-reference/dataframe/creating-a-dataframe.md @@ -11,7 +11,7 @@ danfo.**DataFrame**(data, options) | data | 2D Array, 2D Tensor, JSON object. | Flat data structure to load into DataFrame | | options | Object |

Optional configuration object. Supported properties are:

index: Array of numeric or string names for subseting array. If not specified, indexes are auto-generated.

columns: Array of column names. If not specified, column names are auto generated.

dtypes: Array of data types for each the column. If not specified, dtypes are/is inferred.

config: General configuration object for extending or setting NDframe behavior. See full options here

| -In order to create a DataFrame, you new to call the new Keyword and pass in a flat data structure. In the following examples, we show you how to create DataFrames by specifying different config options. +In order to create a DataFrame, you need to call the new Keyword and pass in a flat data structure. In the following examples, we show you how to create DataFrames by specifying different config options. ### Creating a `DataFrame` from a JSON object: @@ -40,7 +40,7 @@ df.print() - Document + Document @@ -85,7 +85,7 @@ df.print() - Document + Document @@ -142,7 +142,7 @@ df.ctypes.print() - Document + Document @@ -220,7 +220,7 @@ df.print() - Document + Document diff --git a/api-reference/dataframe/danfo.dataframe.cumsum.md b/api-reference/dataframe/danfo.dataframe.cumsum.md index a2585fe..ce997aa 100644 --- a/api-reference/dataframe/danfo.dataframe.cumsum.md +++ b/api-reference/dataframe/danfo.dataframe.cumsum.md @@ -64,7 +64,7 @@ data = [[11, 20, 3], [1, 15, 6], [2, 30, 40], [2, 89, 78]] cols = ["A", "B", "C"] let df = new dfd.DataFrame(data, { columns: cols }) -let new_df = df.cumsum({ axis: 1 }) +let new_df = df.cumSum({ axis: 1 }) new_df.print() ``` diff --git a/api-reference/dataframe/danfo.dataframe.diff.md b/api-reference/dataframe/danfo.dataframe.diff.md new file mode 100644 index 0000000..3b15c8a --- /dev/null +++ b/api-reference/dataframe/danfo.dataframe.diff.md @@ -0,0 +1,313 @@ +--- +description: >- + Get difference between a dataframe and other. Accepts DataFrame, Series, number[] and number. +--- + +# DataFrame.diff + +danfo.DataFrame.diff(other, option) + +| Parameters | Type | Description | Default | +| ---------- | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------- | +| other | DataFrame, Series, Array or Scalar | Object to calculate difference with | | +| option | Object |

{

axis: 0 for column, 1 for row (default).

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

}

| { axis: 1, inplace: false } | + +## **Examples** + +### Difference with **previous row** of current DataFrame along default axis 1 + +{% tabs %} +{% tab title="Node" %} + +```javascript +import * as dfd from "danfojs"; + +const data = [ + [0, 2, 4], + [10, 10, 10], + [1, 2, 3], +]; + +const df = new dfd.DataFrame(data); + +const df_new = df.diff(1); + +df_new.print(); +``` + +{% endtab %} + +{% tab title="Browser" %} + +```html + + + + + + + + + + + + +``` + +{% endtab %} +{% endtabs %} + +{% tabs %} +{% tab title="Output" %} + +``` +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ Col1 │ Col2 │ Col3 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ NaN │ NaN │ NaN ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ 10 │ 8 │ 6 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 2 │ -9 │ -8 │ -7 ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ + +``` + +{% endtab %} +{% endtabs %} + +### Difference with **following row** of current DataFrame along default axis 1 + +{% tabs %} +{% tab title="Node" %} + +```javascript +import * as dfd from "danfojs"; + +const data = [ + [0, 2, 4], + [10, 10, 10], + [1, 2, 3], +]; + +const df = new dfd.DataFrame(data); + +const df_new = df.diff(-1); + +df_new.print(); +``` + +{% endtab %} + +{% tab title="Browser" %} + +```html + + + + + + + + + + + + +``` + +{% endtab %} +{% endtabs %} + +{% tabs %} +{% tab title="Output" %} + +``` +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ Col1 │ Col2 │ Col3 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ -10 │ -8 │ -6 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ 10 │ 8 │ 6 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 2 │ NaN │ NaN │ NaN ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ + +``` + +{% endtab %} +{% endtabs %} + +### Difference with **Series** and DataFrame along axis 1 + +{% tabs %} +{% tab title="Node" %} + +```javascript +import * as dfd from "danfojs"; + +const data = [ + [0, 2, 4], + [10, 10, 10], + [1, 2, 3], +]; + +const df = new dfd.DataFrame(data); + +const sf = new dfd.Series([1, 2, 1]); + +const df_new = df.diff(sf); + +df_new.print(); +``` + +{% endtab %} + +{% tab title="Browser" %} + +```html + + + + + + + + + + + + +``` + +{% endtab %} +{% endtabs %} + +{% tabs %} +{% tab title="Output" %} + +``` +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ Col1 │ Col2 │ Col3 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ -1 │ 0 │ 3 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ 9 │ 8 │ 9 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 2 │ 0 │ 0 │ 2 ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ + +``` + +{% endtab %} +{% endtabs %} + +### Difference between DataFrame and **another** DataFrame + +{% tabs %} +{% tab title="Node" %} + +```javascript +import * as dfd from "danfojs"; + +const data = [ + [0, 2, 4], + [3, 10, 4], +]; + +const original_df = new dfd.DataFrame(data); + +const comparison_df = new dfd.DataFrame([ + [-1, -2, 4], + [10, 5, 0], +]); + +const df_new = original_df.diff(comparison_df); + +df_new.print(); +``` + +{% endtab %} + +{% tab title="Browser" %} + +```html + + + + + + + + + + + + +``` + +{% endtab %} +{% endtabs %} + +{% tabs %} +{% tab title="Output" %} + +``` +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ Col1 │ Col2 │ Col3 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ 1 │ 4 │ 0 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ -7 │ 5 │ 4 ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ + +``` + +{% endtab %} +{% endtabs %} diff --git a/api-reference/dataframe/danfo.dataframe.groupby.md b/api-reference/dataframe/danfo.dataframe.groupby.md index b0adffc..30f4721 100644 --- a/api-reference/dataframe/danfo.dataframe.groupby.md +++ b/api-reference/dataframe/danfo.dataframe.groupby.md @@ -65,7 +65,7 @@ A groupby operation will return a GroupBy class object. You can apply any of the 6. [cumSum](danfo.dataframe.cumsum.md) 7. [cumMax](danfo.dataframe.cummax.md) 8. [cumProd](danfo.dataframe.cumprod.md) -9. [cummin](danfo.dataframe.cummin.md) +9. [cumMin](danfo.dataframe.cummin.md) 10. [max](danfo.dataframe.max.md) 11. [min](danfo.dataframe.min.md) diff --git a/api-reference/dataframe/danfo.dataframe.mod.md b/api-reference/dataframe/danfo.dataframe.mod.md index f3cda7c..7979969 100644 --- a/api-reference/dataframe/danfo.dataframe.mod.md +++ b/api-reference/dataframe/danfo.dataframe.mod.md @@ -53,7 +53,6 @@ df_new.print() ║ 3 │ 0 │ 0 ║ ╚════════════╧═══════════════════╧═══════════════════╝ - ``` {% endtab %} {% endtabs %} @@ -100,7 +99,6 @@ df_new.print() ║ 3 │ 1 │ 4 ║ ╚════════════╧═══════════════════╧═══════════════════╝ - ``` {% endtab %} {% endtabs %} @@ -148,7 +146,6 @@ df_new.print() ║ 3 │ 0 │ 0 ║ ╚════════════╧═══════════════════╧═══════════════════╝ - ``` {% endtab %} {% endtabs %} @@ -194,7 +191,6 @@ df_new.print() ╟────────────┼───────────────────┼───────────────────╢ ║ 3 │ 0 │ 0 ║ ╚════════════╧═══════════════════╧═══════════════════╝ - ``` {% endtab %} {% endtabs %} @@ -241,7 +237,6 @@ df.print() ║ 3 │ 0 │ 0 ║ ╚════════════╧═══════════════════╧═══════════════════╝ - ``` {% endtab %} {% endtabs %} diff --git a/api-reference/dataframe/danfo.dataframe.mul.md b/api-reference/dataframe/danfo.dataframe.mul.md index 41b2baf..a2e0071 100644 --- a/api-reference/dataframe/danfo.dataframe.mul.md +++ b/api-reference/dataframe/danfo.dataframe.mul.md @@ -4,7 +4,7 @@ description: Get Multiplication of dataframe and other, element-wise (binary ope # DataFrame.mul -danfo.DataFrame.mul(other, option) +danfo.DataFrame.mul(other, option) | Parameters | Type | Description | Default | | ---------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------- | @@ -143,7 +143,6 @@ df_new.print() ╟────────────┼───────────────────┼───────────────────╢ ║ 3 │ 0 │ 8 ║ ╚════════════╧═══════════════════╧═══════════════════╝ - ``` {% endtab %} {% endtabs %} @@ -190,7 +189,6 @@ df_new.print() ║ 3 │ 20 │ 48 ║ ╚════════════╧═══════════════════╧═══════════════════╝ - ``` {% endtab %} {% endtabs %} @@ -236,7 +234,6 @@ df.print() ╟────────────┼───────────────────┼───────────────────╢ ║ 3 │ 20 │ 48 ║ ╚════════════╧═══════════════════╧═══════════════════╝ - ``` {% endtab %} {% endtabs %} diff --git a/api-reference/dataframe/danfo.dataframe.pctChange.md b/api-reference/dataframe/danfo.dataframe.pctChange.md new file mode 100644 index 0000000..542029f --- /dev/null +++ b/api-reference/dataframe/danfo.dataframe.pctChange.md @@ -0,0 +1,305 @@ +--- +description: >- + Get percent difference between a dataframe and other. Accepts DataFrame, Series, number[] and number. +--- + +# DataFrame.pctChange + +danfo.DataFrame.pctChange(other, option) + +| Parameters | Type | Description | Default | +| ---------- | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------- | +| other | DataFrame, Series, Array or Scalar | Object to calculate difference with | | +| option | Object |

{

axis: 0 for column, 1 for row (default).

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

}

| { axis: 1, inplace: false } | + +## **Examples** + +### Percent difference with **previous row** of current DataFrame along default axis 1 + +{% tabs %} +{% tab title="Node" %} + +```javascript +import * as dfd from "danfojs"; + +const data = [[90], [900], [900]]; + +const df = new dfd.DataFrame(data); + +const df_new = df.pctChange(1); + +df_new.print(); +``` + +{% endtab %} + +{% tab title="Browser" %} + +```html + + + + + + + + + + + + +``` + +{% endtab %} +{% endtabs %} + +{% tabs %} +{% tab title="Output" %} + +``` +╔════════════╤═══════════════════╗ +║ │ Col1 ║ +╟────────────┼───────────────────╢ +║ 0 │ NaN ║ +╟────────────┼───────────────────╢ +║ 1 │ 9 ║ +╟────────────┼───────────────────╢ +║ 2 │ 0 ║ +╚════════════╧═══════════════════╝ + +``` + +{% endtab %} +{% endtabs %} + +### Percentage difference with **following row** of current DataFrame along default axis 1 + +{% tabs %} +{% tab title="Node" %} + +```javascript +import * as dfd from "danfojs"; + +const data = [ + [0, 5, 15], + [10, 10, 10], + [1, 2, 5], +]; + +const df = new dfd.DataFrame(data); + +const df_new = df.pctChange(-1); + +df_new.print(); +``` + +{% endtab %} + +{% tab title="Browser" %} + +```html + + + + + + + + + + + + +``` + +{% endtab %} +{% endtabs %} + +{% tabs %} +{% tab title="Output" %} + +``` +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ Col1 │ Col2 │ Col3 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ -1 │ -0.5 │ 0.5 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ 9 │ 4 │ 1 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 2 │ NaN │ NaN │ NaN ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ + +``` + +{% endtab %} +{% endtabs %} + +### Percentage difference with **Series** and DataFrame along axis 1 + +{% tabs %} +{% tab title="Node" %} + +```javascript +import * as dfd from "danfojs"; + +const data = [ + [0, 2, 4], + [10, 10, 10], + [1, 2, 3], +]; + +const df = new dfd.DataFrame(data); + +const sf = new dfd.Series([1, 2, 1]); + +const df_new = df.pctChange(sf); + +df_new.print(); +``` + +{% endtab %} + +{% tab title="Browser" %} + +```html + + + + + + + + + + + + +``` + +{% endtab %} +{% endtabs %} + +{% tabs %} +{% tab title="Output" %} + +``` +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ Col1 │ Col2 │ Col3 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ -1 │ 0 │ 3 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ 9 │ 4 │ 9 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 2 │ 0 │ 0 │ 2 ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ + +``` + +{% endtab %} +{% endtabs %} + +### Percentage difference between DataFrame and **another** DataFrame + +{% tabs %} +{% tab title="Node" %} + +```javascript +import * as dfd from "danfojs"; + +const data = [ + [0, 2, 4], + [3, 10, 4], +]; + +const original_df = new dfd.DataFrame(data); + +const comparison_df = new dfd.DataFrame([ + [-1, -2, 4], + [6, 5, 0], +]); + +const df_new = original_df.pctChange(comparison_df); + +df_new.print(); +``` + +{% endtab %} + +{% tab title="Browser" %} + +```html + + + + + + + + + + + + +``` + +{% endtab %} +{% endtabs %} + +{% tabs %} +{% tab title="Output" %} + +``` +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ Col1 │ Col2 │ Col3 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ -1 │ -2 │ 0 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ -0.5 │ 1 │ -1 ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ + +``` + +{% endtab %} +{% endtabs %} diff --git a/api-reference/dataframe/danfo.dataframe.pow.md b/api-reference/dataframe/danfo.dataframe.pow.md index 8a1bae7..1f2926d 100644 --- a/api-reference/dataframe/danfo.dataframe.pow.md +++ b/api-reference/dataframe/danfo.dataframe.pow.md @@ -6,7 +6,7 @@ description: >- # DataFrame.pow -danfo.DataFrame.pow(other, option) +danfo.DataFrame.pow(other, option) | Parameters | Type | Description | Default | | ---------- | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------- | @@ -55,7 +55,6 @@ df_new.print() ║ 3 │ 100 │ 576 ║ ╚════════════╧═══════════════════╧═══════════════════╝ - ``` {% endtab %} {% endtabs %} @@ -102,7 +101,6 @@ df_new.print() ║ 3 │ 1 │ 1024 ║ ╚════════════╧═══════════════════╧═══════════════════╝ - ``` {% endtab %} {% endtabs %} @@ -150,7 +148,6 @@ df_new.print() ║ 3 │ 0 │ 16 ║ ╚════════════╧═══════════════════╧═══════════════════╝ - ``` {% endtab %} {% endtabs %} @@ -196,7 +193,6 @@ df_new.print() ╟────────────┼───────────────────┼───────────────────╢ ║ 3 │ 100 │ 576 ║ ╚════════════╧═══════════════════╧═══════════════════╝ - ``` {% endtab %} {% endtabs %} @@ -243,7 +239,6 @@ df.print() ║ 3 │ 100 │ 576 ║ ╚════════════╧═══════════════════╧═══════════════════╝ - ``` {% endtab %} {% endtabs %} diff --git a/api-reference/dataframe/dataframe.astype.md b/api-reference/dataframe/dataframe.astype.md index 45adf39..5e0d9cd 100644 --- a/api-reference/dataframe/dataframe.astype.md +++ b/api-reference/dataframe/dataframe.astype.md @@ -8,7 +8,7 @@ danfo.DataFrame.asType(options) | Parameters | Type | Description | Default | | ---------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | -| options | Object |

{

column: Array, label/column name of column to cast

dtype: dtype to cast to. One of [string, float32, int32, boolean]

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

}

| { inplace: false } | +| options | Object |

{

column: String, label/column name of column to cast

dtype: dtype to cast to. One of [string, float32, int32, boolean]

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

}

| { inplace: false } | ## **Examples** diff --git a/api-reference/dataframe/dataframe.at.md b/api-reference/dataframe/dataframe.at.md new file mode 100644 index 0000000..180413d --- /dev/null +++ b/api-reference/dataframe/dataframe.at.md @@ -0,0 +1,36 @@ +--- +description: Access a single value for a row/column label pair. +--- + +# DataFrame.at + +> danfo.DataFrame.at(row, column) + +| Parameters | Type | Description | Default | +| ---------- | -------------- | ------------------------- | ------- | +| row | Number, String | row position in the index | | +| column | String | Column position | | + +**Return:** Scalar + + + +{% tabs %} +{% tab title="Node" %} +```javascript +const dfd = require("danfojs-node") + +let data = { + "Name": ["Apples", "Mango", "Banana", "Pear"], + "Count": [21, 5, 30, 10], + "Price": [200, 300, 40, 250] +} + +let df = new dfd.DataFrame(data, { index: [1, "b", "c", "d"] }) +df.at(1, "Count") + +//output +21 +``` +{% endtab %} +{% endtabs %} diff --git a/api-reference/dataframe/dataframe.iat.md b/api-reference/dataframe/dataframe.iat.md new file mode 100644 index 0000000..c50f4f3 --- /dev/null +++ b/api-reference/dataframe/dataframe.iat.md @@ -0,0 +1,36 @@ +--- +description: Access a single value for a row/column pair by integer position. +--- + +# DataFrame.iat + +> danfo.DataFrame.iat(row, column) + +| Parameters | Type | Description | Default | +| ---------- | ------ | --------------------- | ------- | +| row | Number | row index position | | +| column | Number | Column index position | | + +**Return:** Scalar + + + +{% tabs %} +{% tab title="Node" %} +```javascript +const dfd = require("danfojs-node") + +let data = { + "Name": ["Apples", "Mango", "Banana", "Pear"], + "Count": [21, 5, 30, 10], + "Price": [200, 300, 40, 250] +} + +let df = new dfd.DataFrame(data, { index: [1, "b", "c", "d"] }) +df.iat(1, 2) + +//output +300 +``` +{% endtab %} +{% endtabs %} diff --git a/api-reference/dataframe/dataframe.sort_values.md b/api-reference/dataframe/dataframe.sort_values.md index 9aedc7b..03b8981 100644 --- a/api-reference/dataframe/dataframe.sort_values.md +++ b/api-reference/dataframe/dataframe.sort_values.md @@ -6,10 +6,10 @@ description: Sort a Dataframe in ascending or descending order by a specified co danfo.DataFrame.**sortValues**(by, options) \[[source](https://github.com/opensource9ja/danfojs/blob/cf5c7ae3a009458e61eedd18d9c9b5b6b10d5276/danfojs/src/core/frame.js#L125)] -| Parameters | Type | Description | Default | -| ---------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | -| **by** | Object | This key can be either a single column name or a single array of the same length as the calling DataFrame. | | -| options | Object |

Optional configuration:

ascending: Order of sorting

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

|

{

ascending: true, inplace: false

}

| +| Parameters | Type | Description | Default | +| ---------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------- | +| **by** | Object | This key can be either a single column name or a single array of the same length as the calling DataFrame. | | +| options | Object |

Optional configuration:

ascending: Order of sorting

inplace: Boolean indicating whether to perform the operation inplace or not. Defaults to false

|

{

ascending: true, inplace: false

}

| ## **Examples** @@ -86,9 +86,9 @@ df.print() ╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ ║ │ A │ B │ C ║ ╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ -20 │ 34 │ 20 ║ +║ 0 │ 47.3 │ 6 │ 30 ║ ╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 47.3 │ 6 │ 30 ║ +║ 2 │ -20 │ 34 │ 20 ║ ╟────────────┼───────────────────┼───────────────────┼───────────────────╢ ║ 1 │ 30 │ 5 │ 3 ║ ╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ diff --git a/api-reference/dataframe/dataframe.to_csv.md b/api-reference/dataframe/dataframe.to_csv.md index 504cbcc..101cb4b 100644 --- a/api-reference/dataframe/dataframe.to_csv.md +++ b/api-reference/dataframe/dataframe.to_csv.md @@ -4,12 +4,16 @@ description: Convert DataFrame to a comma-separated values (CSV) # DataFrame.toCSV -DataFrame.toCSV(options) +{% hint style="danger" %} +Deprecated in v1.1.0: Use the [`dfd.toCSV`](../input-output/danfo.to\_csv.md) function directly instead +{% endhint %} -| | | | | -| -------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | -| **Parameters** | Type | Description | Default | -| **options** | object, optional |

Configuration object:

filePath: Local file path to write the CSV file to. If not specified, the CSV will be returned as a string. Only needed in Nodejs version


fileName: The name of the file to download as. Only needed in browser environment.


download: Boolean indicating whether to automatically download the CSV file in the browser. Only needed in the browser environment.

header: Boolean indicating whether to include a header row in the CSV file.

sep: Character to be used as a separator in the CSV file.

|

{
sep: ","
}

| +DataFrame.toCSV(options) + +| | | | | +| -------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ | +| **Parameters** | Type | Description | Default | +| **options** | object, optional |

Configuration object:

filePath: Local file path to write the CSV file to. If not specified, the CSV will be returned as a string. Only needed in Nodejs version


fileName: The name of the file to download as. Only needed in browser environment.


download: Boolean indicating whether to automatically download the CSV file in the browser. Only needed in the browser environment.

header: Boolean indicating whether to include a header row in the CSV file.

sep: Character to be used as a separator in the CSV file.

|

{
sep: ","
}

| The **toCSV** function can be used to write out a DataFrame or Series to CSV file. The output is configurable and will depend on the environment. In the following examples, we show you how to write/download a CSV file from Node and Browser environments. @@ -49,7 +53,7 @@ Abs,Count,country code - + Document @@ -65,7 +69,7 @@ Abs,Count,country code let df = new dfd.DataFrame(data); - const csv = df.to_csv({ download: false }); + const csv = df.toCSV({ download: false }); console.log(csv); diff --git a/api-reference/dataframe/dataframe.to_excel.md b/api-reference/dataframe/dataframe.to_excel.md index 38f6abb..7157518 100644 --- a/api-reference/dataframe/dataframe.to_excel.md +++ b/api-reference/dataframe/dataframe.to_excel.md @@ -6,11 +6,15 @@ description: >- # DataFrame.toExcel -> DataFrame.toExcel(options) +{% hint style="danger" %} +Deprecated in v1.1.0: Use the [`dfd.toExcel`](../input-output/danfo.to\_excel.md) function directly instead +{% endhint %} -| **Parameters** | Type | Description | Default | -| -------------- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -| **options** | object, optional |

Configuration object:

filePath: Local file path to write the CSV file to. If not specified, the CSV will be returned as a string. Only needed in Nodejs version


fileName: The name of the file to download as. Only needed in the browser environment.


sheetName: Name to call the excel sheet.

|

{
filePath: "./output.xlsx",
sheetName: "Sheet1"

}

| +> DataFrame.toExcel(options) + +| **Parameters** | Type | Description | Default | +| -------------- | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | +| **options** | object, optional |

Configuration object:

filePath: Local file path to write the CSV file to. If not specified, the CSV will be returned as a string. Only needed in Nodejs version


fileName: The name of the file to download as. Only needed in the browser environment.


sheetName: Name to call the excel sheet.

|

{
filePath: "./output.xlsx",
sheetName: "Sheet1"

}

| The **toExcel** function can be used to write out a DataFrame or Series to Excel (**.xlsx**) file. The output format will depend on the environment. In the following examples, we show you how to write/download an Excel file from Node and Browser environments. diff --git a/api-reference/dataframe/dataframe.to_json.md b/api-reference/dataframe/dataframe.to_json.md index b1f043a..3a6f4db 100644 --- a/api-reference/dataframe/dataframe.to_json.md +++ b/api-reference/dataframe/dataframe.to_json.md @@ -4,12 +4,16 @@ description: Convert DataFrame to JSON format # DataFrame.toJSON -> DataFrame.toJSON(options) +{% hint style="danger" %} +Deprecated in v1.1.0: Use the [dfd.toJSON](../input-output/danfo.to\_json.md) function directly instead +{% endhint %} -| | | | | -| -------------- | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- | -| **Parameters** | Type | Description | Default | -| **options** | object, optional |

Configuration object:

filePath: Local file path to write the CSV file to. If not specified, the CSV will be returned as a string. Only needed in Nodejs version


fileName: The name of the file to download as. Only needed in browser environment.


format: The format of the JSON. Can be one of row or column.

|

{
format: "column"
}

| +> DataFrame.toJSON(options) + +| | | | | +| -------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------- | +| **Parameters** | Type | Description | Default | +| **options** | object, optional |

Configuration object:

filePath: Local file path to write the CSV file to. If not specified, the CSV will be returned as a string. Only needed in Nodejs version


fileName: The name of the file to download as. Only needed in browser environment.


format: The format of the JSON. Can be one of row or column.

|

{
format: "column"
}

| The **toJSON** function can be used to write out a DataFrame or Series to JSON format/file. The output is configurable and will depend on the environment. In the following examples, we show you how to write/download a JSON file from Node and Browser environments. @@ -62,7 +66,7 @@ console.log(jsonObjRow); - + Document @@ -78,7 +82,7 @@ console.log(jsonObjRow); let df = new dfd.DataFrame(data); - const csv = df.to_csv({ download: false }); + const csv = df.toCSV({ download: false }); console.log(csv); diff --git a/api-reference/general-functions/danfo.dt.md b/api-reference/general-functions/danfo.dt.md index 766aacc..1e5b59b 100644 --- a/api-reference/general-functions/danfo.dt.md +++ b/api-reference/general-functions/danfo.dt.md @@ -4,12 +4,12 @@ description: Accessor object for date time properties of the Series values. # danfo.Dt -For example, in the following example, we convert a Series to an `Dt` instance and apply a couple of **DateTime** methods. +For example, in the following example, we convert a Series to an `Dt` instance and apply a couple of **DateTime** methods. {% tabs %} {% tab title="Node" %} ```javascript -import { Dt, Series } from "danfojs-node-nightly" +import { Dt, Series } from "danfojs-node" const sf = new Series(["1/1/2000", "1/2/2000", "2/3/2000", "1/4/2000", "4/5/2000"]) const dtS = new Dt(sf) @@ -45,5 +45,4 @@ dtS.monthName().print() ╟───┼──────────╢ ║ 4 │ April ║ ╚═══╧══════════╝ - ``` diff --git a/api-reference/general-functions/danfo.streamcsvtransformer.md b/api-reference/general-functions/danfo.streamcsvtransformer.md index 922dd43..30363fc 100644 --- a/api-reference/general-functions/danfo.streamcsvtransformer.md +++ b/api-reference/general-functions/danfo.streamcsvtransformer.md @@ -7,31 +7,29 @@ description: >- # danfo.streamCsvTransformer -danfo.**streamCsvTransformer**(func) +danfo.**streamCsvTransformer**(func) | Parameters | Type | Description | | ------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | inputFilePath | Function | The path to the CSV file to stream from. | -| transformer | Function |

The transformer function to apply to each row.

Note that each row of the CSV file is passed as a DataFrame with a single row to the transformer function, and the transformer function is expected to return a transformed DataFrame.

| +| transformer | Function |

The transformer function to apply to each row.

Note that each row of the CSV file is passed as a DataFrame with a single row to the transformer function, and the transformer function is expected to return a transformed DataFrame.

| | options | object |

Configuration options for the pipeline. These include:

  • outputFilePath The local file path to write the transformed CSV file to.
  • customCSVStreamWriter A custom CSV stream writer function. This is applied at the end of each transform. If not provided, a default CSV stream writer is used, and this writes to local storage.
  • inputStreamOptions Configuration options for the input stream. Supports all Papaparse CSV reader config options.
  • outputStreamOptions Configuration options for the output stream. This is only applied when using the default CSV stream writer. Supports all toCSV options.
| **Returns:** -> return A promise that resolves when the pipeline transformation is complete. +> A promise that resolves when the pipeline transformation is complete. The streamCsvTransformer can be used to [incrementally transform](https://en.wikipedia.org/wiki/Stream\_processing) a CSV file. This is done by: * Streaming a CSV file from a local or **remote** path. * Passing each corresponding row as a DataFrame to the specified transformer function. -* Writing the result to an output stream. - - +* Writing the result to an output stream. ## **Stream processing a local file** -In the example below, we stream a local CSV file (titanic.csv), applies a transformer function, and write the output to the `titanicOutLocal` file. +In the example below, we stream a local CSV file (titanic.csv), apply a transformer function, and write the output to **`titanicOutLocal.csv`**. -The transformer takes each `Name` column, splits the person's title, and creates a new column from it. +The transformer takes each `Name` column, splits the person's title, and creates a new column from it. {% tabs %} {% tab title="Node" %} @@ -86,7 +84,7 @@ PassengerId,Survived,Pclass,Name,Sex,Age,SibSp,Parch,Ticket,Fare,Cabin,Embarked, In the example below, we stream a remote CSV file (titanic.csv), applies a transformer function, and write the output to the `titanicOutLocal` file. -The transformer takes each `Name` column, splits the person's title, and creates a new column from it. +The transformer takes each `Name` column, splits the person's title, and creates a new column from it. {% tabs %} {% tab title="Node" %} @@ -121,7 +119,7 @@ dfd.streamCsvTransformer(inputFilePath, transformer, { If you need custom control of the output writer, then you can provide a pipe-able custom writer. See [https://www.freecodecamp.org/news/node-js-streams-everything-you-need-to-know-c9141306be93/](https://www.freecodecamp.org/news/node-js-streams-everything-you-need-to-know-c9141306be93/) -In the example below, we add a custom writer that logs each row. You can extend this to upload each chunk to a database, or any other function you need. +In the example below, we add a custom writer that logs each row. You can extend this to upload each chunk to a database, or any other function you need. {% tabs %} {% tab title="Node" %} diff --git a/api-reference/groupby.md b/api-reference/groupby.md index 1db2e52..50a8170 100644 --- a/api-reference/groupby.md +++ b/api-reference/groupby.md @@ -37,11 +37,11 @@ description: >- | [`GroupBy.bfill`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.bfill.html#pandas.core.groupby.GroupBy.bfill)\(\[limit\]\) | Backward fill the values. | | [`GroupBy.backfill`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.backfill.html#pandas.core.groupby.GroupBy.backfill)\(\[limit\]\) | Backward fill the values. | | [`GroupBy.count`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.count.html#pandas.core.groupby.GroupBy.count)\(\) | Compute count of group, excluding missing values. | -| [`GroupBy.cumcount`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.cumcount.html#pandas.core.groupby.GroupBy.cumcount)\(\[ascending\]\) | Number each item in each group from 0 to the length of that group - 1. | -| [`GroupBy.cummax`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.cummax.html#pandas.core.groupby.GroupBy.cummax)\(\[axis\]\) | Cumulative max for each group. | -| [`GroupBy.cummin`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.cummin.html#pandas.core.groupby.GroupBy.cummin)\(\[axis\]\) | Cumulative min for each group. | -| [`GroupBy.cumprod`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.cumprod.html#pandas.core.groupby.GroupBy.cumprod)\(\[axis\]\) | Cumulative product for each group. | -| [`GroupBy.cumsum`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.cumsum.html#pandas.core.groupby.GroupBy.cumsum)\(\[axis\]\) | Cumulative sum for each group. | +| [`GroupBy.cumCount`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.cumcount.html#pandas.core.groupby.GroupBy.cumcount)\(\[ascending\]\) | Number each item in each group from 0 to the length of that group - 1. | +| [`GroupBy.cumMax`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.cummax.html#pandas.core.groupby.GroupBy.cummax)\(\[axis\]\) | Cumulative max for each group. | +| [`GroupBy.cumMin`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.cummin.html#pandas.core.groupby.GroupBy.cummin)\(\[axis\]\) | Cumulative min for each group. | +| [`GroupBy.cumProd`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.cumprod.html#pandas.core.groupby.GroupBy.cumprod)\(\[axis\]\) | Cumulative product for each group. | +| [`GroupBy.cumSum`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.cumsum.html#pandas.core.groupby.GroupBy.cumsum)\(\[axis\]\) | Cumulative sum for each group. | | [`GroupBy.ffill`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.ffill.html#pandas.core.groupby.GroupBy.ffill)\(\[limit\]\) | Forward fill the values. | | [`GroupBy.first`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.first.html#pandas.core.groupby.GroupBy.first)\(\[numeric\_only, min\_count\]\) | Compute first of group values. | | [`GroupBy.head`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.head.html#pandas.core.groupby.GroupBy.head)\(\[n\]\) | Return first n rows of each group. | @@ -74,11 +74,11 @@ The following methods are available in both `SeriesGroupBy` and `DataFrameGroupB | [`DataFrameGroupBy.corr`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.corr.html#pandas.core.groupby.DataFrameGroupBy.corr) | Compute pairwise correlation of columns, excluding NA/null values. | | [`DataFrameGroupBy.count`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.count.html#pandas.core.groupby.DataFrameGroupBy.count)\(\) | Compute count of group, excluding missing values. | | [`DataFrameGroupBy.cov`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.cov.html#pandas.core.groupby.DataFrameGroupBy.cov) | Compute pairwise covariance of columns, excluding NA/null values. | -| [`DataFrameGroupBy.cumcount`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.cumcount.html#pandas.core.groupby.DataFrameGroupBy.cumcount)\(\[ascending\]\) | Number each item in each group from 0 to the length of that group - 1. | -| [`DataFrameGroupBy.cummax`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.cummax.html#pandas.core.groupby.DataFrameGroupBy.cummax)\(\[axis\]\) | Cumulative max for each group. | -| [`DataFrameGroupBy.cummin`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.cummin.html#pandas.core.groupby.DataFrameGroupBy.cummin)\(\[axis\]\) | Cumulative min for each group. | -| [`DataFrameGroupBy.cumprod`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.cumprod.html#pandas.core.groupby.DataFrameGroupBy.cumprod)\(\[axis\]\) | Cumulative product for each group. | -| [`DataFrameGroupBy.cumsum`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.cumsum.html#pandas.core.groupby.DataFrameGroupBy.cumsum)\(\[axis\]\) | Cumulative sum for each group. | +| [`DataFrameGroupBy.cumCount`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.cumcount.html#pandas.core.groupby.DataFrameGroupBy.cumcount)\(\[ascending\]\) | Number each item in each group from 0 to the length of that group - 1. | +| [`DataFrameGroupBy.cumMax`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.cummax.html#pandas.core.groupby.DataFrameGroupBy.cummax)\(\[axis\]\) | Cumulative max for each group. | +| [`DataFrameGroupBy.cumMin`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.cummin.html#pandas.core.groupby.DataFrameGroupBy.cummin)\(\[axis\]\) | Cumulative min for each group. | +| [`DataFrameGroupBy.cumProd`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.cumprod.html#pandas.core.groupby.DataFrameGroupBy.cumprod)\(\[axis\]\) | Cumulative product for each group. | +| [`DataFrameGroupBy.cumSum`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.cumsum.html#pandas.core.groupby.DataFrameGroupBy.cumsum)\(\[axis\]\) | Cumulative sum for each group. | | [`DataFrameGroupBy.describe`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.describe.html#pandas.core.groupby.DataFrameGroupBy.describe)\(\*\*kwargs\) | Generate descriptive statistics. | | [`DataFrameGroupBy.diff`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.diff.html#pandas.core.groupby.DataFrameGroupBy.diff) | First discrete difference of element. | | [`DataFrameGroupBy.ffill`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.DataFrameGroupBy.ffill.html#pandas.core.groupby.DataFrameGroupBy.ffill)\(\[limit\]\) | Forward fill the values. | diff --git a/api-reference/groupby/README.md b/api-reference/groupby/README.md index 9a1db65..7e37891 100644 --- a/api-reference/groupby/README.md +++ b/api-reference/groupby/README.md @@ -8,7 +8,7 @@ description: 'GroupBy objects are returned by groupby calls: danfo.DataFrame.gro | | | | :--- | :--- | -| [`GroupBy.get_group`](groupby.get_groups.md) | Construct DataFrame from group with provided name. | +| [`GroupBy.get_group`](groupby.getGroup.md) | Construct DataFrame from group with provided name. | ### Function application @@ -21,10 +21,10 @@ description: 'GroupBy objects are returned by groupby calls: danfo.DataFrame.gro | | | | :--- | :--- | | [`GroupBy.count`](groupby.count.md) | Compute count of group, excluding missing values. | -| [`GroupBy.cummax`](groupby.cummax.md) | Cumulative max for each group. | -| [`GroupBy.cummin`](groupby.cummin.md) | Cumulative min for each group. | -| [`GroupBy.cumprod`](groupby.cumprod.md) | Cumulative product for each group. | -| [`GroupBy.cumsum`](groupby.cumsum.md) | Cumulative sum for each group. | +| [`GroupBy.cumMax`](groupby.cummax.md) | Cumulative max for each group. | +| [`GroupBy.cumMin`](groupby.cummin.md) | Cumulative min for each group. | +| [`GroupBy.cumProd`](groupby.cumprod.md) | Cumulative product for each group. | +| [`GroupBy.cumSum`](groupby.cumsum.md) | Cumulative sum for each group. | | [`GroupBy.max`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.max.html#pandas.core.groupby.GroupBy.max) | Compute max of group values. | | [`GroupBy.mean`](groupby.mean.md) | Compute mean of groups, excluding missing values. | | [`GroupBy.min`](groupby.min.md) | Compute min of group values. | diff --git a/api-reference/groupby/groupby.agg.md b/api-reference/groupby/groupby.agg.md index fae8802..fca7d03 100644 --- a/api-reference/groupby/groupby.agg.md +++ b/api-reference/groupby/groupby.agg.md @@ -8,13 +8,15 @@ description: Obtain data aggregate per groups for each column | Parameters | Type | Description | Default | | ---------- | ------ | --------------------------------------------------------------------------------------------------------- | ------- | -| kwargs | Object | kwargs contain keys which are column names in the dataframe, and the values are operation to be performed | | +| ops | Object | keys are column names and `values` are aggregation operator | {} | **Return:** DataFrame **Examples** -Using mean and sum aggregate +**Aggregation using one aggregate operator per column** + +1) Assigning `mean` and `sum` aggregate to different column {% tabs %} {% tab title="Node" %} @@ -33,7 +35,7 @@ let data ={'A': ['foo', 'bar', 'foo', 'bar', let df = new dfd.DataFrame(data) let grp = df.groupby(["A"]) -grp.agg({"C":"mean","D":"sum"}).print() +grp.agg({C:"mean",D:"sum"}).print() ``` {% endtab %} {% endtabs %} @@ -41,16 +43,16 @@ grp.agg({"C":"mean","D":"sum"}).print() ``` Shape: (2,3) -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ C_mean │ D_sum ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 4.19999980926... │ 27 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ bar │ 3 │ 9 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ A │ C_mean │ D_sum ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ foo │ 4.2 │ 27 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ bar │ 3 │ 9 ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ ``` -Mean and Sum aggregate on dataframe groupby two column +2) Mean and Sum aggregate on dataframe grouped by two column {% tabs %} {% tab title="Node" %} @@ -69,25 +71,62 @@ let data ={'A': ['foo', 'bar', 'foo', 'bar', let df = new dfd.DataFrame(data) let grp = df.groupby(["A","B"]) -grp.agg({"C":"mean","D":"sum"}).print() +grp.agg({C:"mean",D:"sum"}).print() ``` {% endtab %} {% endtabs %} ``` - Shape: (5,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_mean │ D_sum ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 3.5 │ 10 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ two │ 3.5 │ 9 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ three │ 7 │ 8 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ bar │ one │ 3 │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ bar │ two │ 2 │ 6 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ A │ B │ C_mean │ D_sum ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ foo │ one │ 3.5 │ 10 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ foo │ two │ 3.5 │ 9 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 2 │ foo │ three │ 7 │ 8 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 3 │ bar │ one │ 3 │ 2 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 4 │ bar │ three │ 4 │ 1 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 5 │ bar │ two │ 2 │ 6 ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ +``` + +**Aggregation using two or more aggregate operator per column** + +Assigning `mean` and `sum`, `min`, `std`, `count` aggregate to different column + +{% tabs %} +{% tab title="Node" %} +```javascript +const dfd = require("danfojs-node") + + +let data ={'A': ['foo', 'bar', 'foo', 'bar', + 'foo', 'bar', 'foo', 'foo'], + 'B': ['one', 'one', 'two', 'three', + 'two', 'two', 'one', 'three'], + 'C': [1,3,2,4,5,2,6,7], + 'D': [3,2,4,1,5,6,7,8] + } + +let df = new dfd.DataFrame(data) + +let grp = df.groupby(["A"]) +grp.agg({C:["mean", "sum", "min"], + D:["sum", "count", "std"]}).print() +``` +{% endtab %} +{% endtabs %} + ``` +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ A │ C_mean │ C_sum │ C_min │ D_sum │ D_count │ D_std ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ foo │ 4.2 │ 21 │ 1 │ 27 │ 5 │ 2.0736441353327… ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ bar │ 3 │ 9 │ 2 │ 9 │ 3 │ 2.6457513110645… ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ +``` \ No newline at end of file diff --git a/api-reference/groupby/groupby.apply.md b/api-reference/groupby/groupby.apply.md index 2150a21..9e01b0e 100644 --- a/api-reference/groupby/groupby.apply.md +++ b/api-reference/groupby/groupby.apply.md @@ -4,11 +4,11 @@ description: Apply custom aggregate function to grouped data # Groupby.apply -danfo.Groupby.**apply**\(callable\) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs-node/src/core/groupby.js#L297)\] +danfo.Groupby.**apply**\(callable\) \[[source](https://github.com/javascriptdata/danfojs/blob/9bfda6dcb6b2b620591ec7b3340d35e3f801c8ab/src/danfojs-base/aggregators/groupby.ts#L552)\] | Parameters | Type | Description | Default | | :--- | :--- | :--- | :--- | -| callable | Function \| function to be applied to grouped data | Undefined | | +| callable | Function \| function to be applied to grouped data. the callable functons takes in DataFrame as argument adn returns DataFrame or Series | Undefined | | **Returns:** @@ -24,26 +24,28 @@ Using apply to create a custom function that subtract the minimum value of each const dfd = require("danfojs-node") let data = { - 'A': ['foo', 'bar', 'foo', 'bar', + A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1, 3, 2, 4, 5, 2, 6, 7], + C: [1, 3, 2, 4, 5, 2, 6, 7], - 'D': [3, 2, 4, 1, 5, 6, 7, 8] + D: [3, 2, 4, 1, 5, 6, 7, 8] }; + let df = new dfd.DataFrame(data); -let group_df = df.groupby(["A", "B"]); +let groupDf = df.groupby(["A", "B"]).col(['C', 'D']); const subMin = (x) => { - return x.sub(x.min()); + //find the min across column + return x.sub(x.min({axis:0})); }; -group_df.apply(subMin).print(); +groupDf.apply(subMin).print(); ``` {% endtab %} @@ -58,25 +60,25 @@ group_df.apply(subMin).print(); {% tabs %} {% tab title="Output" %} ```text -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_apply │ D_apply ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ one │ 5 │ 4 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ two │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ two │ 3 │ 1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ three │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 5 │ bar │ one │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 6 │ bar │ two │ 0 │ 0 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 7 │ bar │ three │ 0 │ 0 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ A │ B │ C │ D ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ foo │ one │ 0 │ 0 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ foo │ one │ 5 │ 4 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 2 │ foo │ two │ 0 │ 0 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 3 │ foo │ two │ 3 │ 1 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 4 │ foo │ three │ 0 │ 0 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 5 │ bar │ one │ 0 │ 0 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 6 │ bar │ three │ 0 │ 0 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 7 │ bar │ two │ 0 │ 0 ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ ``` {% endtab %} {% endtabs %} diff --git a/api-reference/groupby/groupby.col.md b/api-reference/groupby/groupby.col.md index 02e7cdd..7ebc5dd 100644 --- a/api-reference/groupby/groupby.col.md +++ b/api-reference/groupby/groupby.col.md @@ -4,102 +4,97 @@ description: Obtain the column(s) per groups # Groupby.col -> danfo.Groupby.col\(col\_names\) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L104)\] +> danfo.Groupby.col(col\_names) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L104)] -| Parameters | Type | Description | Default | -| :--- | :--- | :--- | :--- | -| col\_names | Array | List of column | | +| Parameters | Type | Description | Default | +| ---------- | ----- | -------------- | ------- | +| col\_names | Array | List of column | | Returns: Groupby Data structure -Note: This is similar to pandas `df.groupby(["column"])["col_names"]` +Note: This is similar to pandas `df.groupby(["column"])["colNames"]` **Examples** -Obtain a column +Obtain the column to perform group aggregate operation on {% tabs %} {% tab title="Node" %} ```javascript const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] } let df = new dfd.DataFrame(data) let grp = df.groupby(["A"]) -grp.col(["C"]) -//for more coumns -grp.col(["C","D"]) +//select single column +let grpColumnC = grp.col(["C"]) + +// convert grouop internal data to dataFrame +grpColumnC.apply(x=> x).print() + +//select multiple column +let grpColumnBD = grp.col(["B", "D"]) + +grpColumnBD.apply(x=> x).print() ``` {% endtab %} {% endtabs %} -Apparently the output are not that useful unless you perform some operations like max\(\), count\(\) and the likes. - -```text -//it returns the groupby data structure -GroupBy { - key_col: [ 'A' ], - col_dict: { - foo: [ [Array], [Array], [Array], [Array], [Array] ], - bar: [ [Array], [Array], [Array] ] - }, - data: [ - [ 'foo', 'one', 1, 3 ], - [ 'bar', 'one', 3, 2 ], - [ 'foo', 'two', 2, 4 ], - [ 'bar', 'three', 4, 1 ], - [ 'foo', 'two', 5, 5 ], - [ 'bar', 'two', 2, 6 ], - [ 'foo', 'one', 6, 7 ], - [ 'foo', 'three', 7, 8 ] - ], - column_name: [ 'A', 'B', 'C', 'D' ], - data_tensors: { - foo: DataFrame { - kwargs: [Object], - series: false, - data: [Array], - row_data_tensor: [Tensor], - index_arr: [Array], - columns: [Array], - col_data: [Array], - col_data_tensor: [Tensor], - col_types: [Array], - A: [Getter/Setter], - B: [Getter/Setter], - C: [Getter/Setter], - D: [Getter/Setter] - }, - bar: DataFrame { - kwargs: [Object], - series: false, - data: [Array], - row_data_tensor: [Tensor], - index_arr: [Array], - columns: [Array], - col_data: [Array], - col_data_tensor: [Tensor], - col_types: [Array], - A: [Getter/Setter], - B: [Getter/Setter], - C: [Getter/Setter], - D: [Getter/Setter] - } - }, - group_col_name: [ 'C' ], - group_col: { foo: [ [Series] ], bar: [ [Series] ] } -} -``` - +Apparently the output are not that useful unless you perform some operations like max(), count() and the likes. +``` +// select single column C + +╔════════════╤═══════════════════╤═══════════════════╗ +║ │ A │ C ║ +╟────────────┼───────────────────┼───────────────────╢ +║ 0 │ foo │ 1 ║ +╟────────────┼───────────────────┼───────────────────╢ +║ 1 │ foo │ 2 ║ +╟────────────┼───────────────────┼───────────────────╢ +║ 2 │ foo │ 5 ║ +╟────────────┼───────────────────┼───────────────────╢ +║ 3 │ foo │ 6 ║ +╟────────────┼───────────────────┼───────────────────╢ +║ 4 │ foo │ 7 ║ +╟────────────┼───────────────────┼───────────────────╢ +║ 5 │ bar │ 3 ║ +╟────────────┼───────────────────┼───────────────────╢ +║ 6 │ bar │ 4 ║ +╟────────────┼───────────────────┼───────────────────╢ +║ 7 │ bar │ 2 ║ +╚════════════╧═══════════════════╧═══════════════════╝ + +// select multiple column: B and D + +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ A │ B │ D ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ foo │ one │ 3 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ foo │ two │ 4 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 2 │ foo │ two │ 5 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 3 │ foo │ one │ 7 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 4 │ foo │ three │ 8 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 5 │ bar │ one │ 2 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 6 │ bar │ three │ 1 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 7 │ bar │ two │ 6 ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ +``` diff --git a/api-reference/groupby/groupby.count.md b/api-reference/groupby/groupby.count.md index 36733be..020893b 100644 --- a/api-reference/groupby/groupby.count.md +++ b/api-reference/groupby/groupby.count.md @@ -12,7 +12,7 @@ description: Count the occurrence of values in columns per groups **Examples** -Obtain the variance of a column for each group, group by one column +Obtain the number of rows per groups {% tabs %} {% tab title="Node" %} @@ -20,27 +20,26 @@ Obtain the variance of a column for each group, group by one column const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) let grp = df.groupby(["A"]) -grp.col(["C"]).count().print() +let grpColumnC = grp.col(["C"]) +grpColumnC.count().print() ``` {% endtab %} {% endtabs %} ``` - Shape: (2,2) - ╔═══╤═══════════════════╤═══════════════════╗ ║ │ A │ C_count ║ ╟───┼───────────────────┼───────────────────╢ @@ -50,7 +49,7 @@ grp.col(["C"]).count().print() ╚═══╧═══════════════════╧═══════════════════╝ ``` -Obtain the var for two columns for each group, group by one column +Obtain the count for two columns for each group, group by one column {% tabs %} {% tab title="Node" %} @@ -58,17 +57,18 @@ Obtain the var for two columns for each group, group by one column const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) let grp = df.groupby(["A"]) + grp.col(["C","D"]).count().print() ``` {% endtab %} @@ -86,6 +86,42 @@ grp.col(["C","D"]).count().print() ╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ ``` +Obtain the count for all columns for each group, group by one column + +{% tabs %} +{% tab title="Node" %} +```javascript +const dfd = require("danfojs-node") + + +let data ={A: ['foo', 'bar', 'foo', 'bar', + 'foo', 'bar', 'foo', 'foo'], + B: ['one', 'one', 'two', 'three', + 'two', 'two', 'one', 'three'], + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} + +let df = new dfd.DataFrame(data) + +let grp = df.groupby(["A"]) + +grp.count().print() +``` +{% endtab %} +{% endtabs %} + +``` +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ A │ B_count │ C_count │ D_count ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ foo │ 5 │ 5 │ 5 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ bar │ 3 │ 3 │ 3 ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ + +``` + Obtain the count for a column for each group, group by two columns {% tabs %} @@ -94,13 +130,13 @@ Obtain the count for a column for each group, group by two columns const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) @@ -112,21 +148,23 @@ grp.col(["C"]).count().print() {% endtabs %} ``` - Shape: (5,3) -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_count ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ two │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ three │ 1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ bar │ one │ 1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ bar │ two │ 1 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ A │ B │ C_count ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ foo │ one │ 2 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ foo │ two │ 2 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 2 │ foo │ three │ 1 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 3 │ bar │ one │ 1 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 4 │ bar │ three │ 1 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 5 │ bar │ two │ 1 ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ + ``` Obtain the count for two columns for each group, group by two columns @@ -137,13 +175,13 @@ Obtain the count for two columns for each group, group by two columns const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) @@ -154,22 +192,23 @@ grp.col(["C","D"]).count().print() {% endtabs %} ``` - - Shape: (5,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_count │ D_count ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 2 │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ two │ 2 │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ three │ 1 │ 1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ bar │ one │ 1 │ 1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ bar │ two │ 1 │ 1 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ + +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ A │ B │ C_count │ D_count ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ foo │ one │ 2 │ 2 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ foo │ two │ 2 │ 2 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 2 │ foo │ three │ 1 │ 1 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 3 │ bar │ one │ 1 │ 1 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 4 │ bar │ three │ 1 │ 1 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 5 │ bar │ two │ 1 │ 1 ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ + ``` **** diff --git a/api-reference/groupby/groupby.cummax.md b/api-reference/groupby/groupby.cumMax.md similarity index 93% rename from api-reference/groupby/groupby.cummax.md rename to api-reference/groupby/groupby.cumMax.md index 8231a61..0f8fe5f 100644 --- a/api-reference/groupby/groupby.cummax.md +++ b/api-reference/groupby/groupby.cumMax.md @@ -2,9 +2,9 @@ description: Obtain the cummulative max per groups for each column --- -# Groupby.cummax +# Groupby.cumMax -> danfo.Groupby.cummax\(\) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L285)\] +> danfo.Groupby.cumMax\(\) \[[source](https://github.com/javascriptdata/danfojs/blob/4993242be7847ba7583dd40ed0188929898b8fd6/src/danfojs-base/aggregators/groupby.ts#L481)\] **Parameters**: None @@ -20,19 +20,19 @@ Obtain the cumulative max of a column for each groups, group by one column const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) let grp = df.groupby(["A"]) -grp.col(["C"]).cummax().head().print() -grp.col(["C"]).cummax().tail().print() +grp.col(["C"]).cumMax().head().print() +grp.col(["C"]).cumMax().tail().print() ``` {% endtab %} {% endtabs %} @@ -73,7 +73,7 @@ Shape: (5,2) ╚═══╧═══════════════════╧═══════════════════╝ ``` -Obtain the cumsum for two columns for each group, group by one column +Obtain the cumMax for two columns for each group, group by one column {% tabs %} {% tab title="Node" %} @@ -81,19 +81,19 @@ Obtain the cumsum for two columns for each group, group by one column const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) let grp = df.groupby(["A"]) -grp.col(["C","D"]).cummax().head().print() -grp.col(["C","D"]).cummax().tail().print() +grp.col(["C","D"]).cumMax().head().print() +grp.col(["C","D"]).cumMax().tail().print() ``` {% endtab %} {% endtabs %} @@ -134,7 +134,7 @@ grp.col(["C","D"]).cummax().tail().print() ╚════╧═══════════════════╧═══════════════════╧═══════════════════╝ ``` -Obtain the cummax for a column for each group, group by two columns +Obtain the cumMax for a column for each group, group by two columns {% tabs %} {% tab title="Node" %} @@ -142,19 +142,19 @@ Obtain the cummax for a column for each group, group by two columns const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) let grp = df.groupby(["A","B"]) -grp.col(["C"]).cummax().head().print() -grp.col(["C"]).cummax().tail().print() +grp.col(["C"]).cumMax().head().print() +grp.col(["C"]).cumMax().tail().print() ``` {% endtab %} @@ -214,8 +214,8 @@ let data ={'A': ['foo', 'bar', 'foo', 'bar', let df = new dfd.DataFrame(data) let grp = df.groupby(["A","B"]) -grp.col(["C","D"]).cummax().head().print() -grp.col(["C","D"]).cummax().tail().print() +grp.col(["C","D"]).cumMax().head().print() +grp.col(["C","D"]).cumMax().tail().print() ``` {% endtab %} {% endtabs %} diff --git a/api-reference-v1-stable/groupby/groupby.cummin.md b/api-reference/groupby/groupby.cumMin.md similarity index 92% rename from api-reference-v1-stable/groupby/groupby.cummin.md rename to api-reference/groupby/groupby.cumMin.md index 7fd9ed6..01f70c3 100644 --- a/api-reference-v1-stable/groupby/groupby.cummin.md +++ b/api-reference/groupby/groupby.cumMin.md @@ -2,9 +2,9 @@ description: Obtain the cummulative minimum per groups for each column --- -# Groupby.cummin +# Groupby.cumMin -> danfo.Groupby.**cummin**\(\) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L297)\] +> danfo.Groupby.**cumMin**\(\) \[[source](https://github.com/javascriptdata/danfojs/blob/4993242be7847ba7583dd40ed0188929898b8fd6/src/danfojs-base/aggregators/groupby.ts#L497)\] **Parameters**: None @@ -20,19 +20,21 @@ Obtain the cumulative min of a column for each groups, group by one column const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) let grp = df.groupby(["A"]) -grp.col(["C"]).cummin().head().print() -grp.col(["C"]).cummin().tail().print() +let grpColC = grp.col(["C"]) +grpColC.cumMin().head().print() +grpColC.cumMin().tail().print() + ``` {% endtab %} {% endtabs %} @@ -73,7 +75,7 @@ grp.col(["C"]).cummin().tail().print() ╚═══╧═══════════════════╧═══════════════════╝ ``` -Obtain the cummin for two columns for each group, group by one column +Obtain the cumMin for two columns for each group, group by one column {% tabs %} {% tab title="Node" %} @@ -81,19 +83,20 @@ Obtain the cummin for two columns for each group, group by one column const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) let grp = df.groupby(["A"]) -grp.col(["C","D"]).cummin().head().print() -grp.col(["C","D"]).cummin().tail().print() +let grpCol = grp.col("C","D"]) +grpCol.cumMin().head().print() +grpCol.cumMin().tail().print() ``` {% endtab %} {% endtabs %} @@ -134,7 +137,7 @@ grp.col(["C","D"]).cummin().tail().print() ╚════╧═══════════════════╧═══════════════════╧═══════════════════╝ ``` -Obtain the cummin for a column for each group, group by two columns +Obtain the cumMin for a column for each group, group by two columns {% tabs %} {% tab title="Node" %} @@ -142,19 +145,20 @@ Obtain the cummin for a column for each group, group by two columns const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) let grp = df.groupby(["A","B"]) -grp.col(["C"]).cummin().head().print() -grp.col(["C"]).cummin().tail().print() +let grpCol = grp.col(["C"]) +grpCol.cumMin().head().print() +grpCol.cumMin().tail().print() ``` {% endtab %} @@ -203,19 +207,20 @@ Obtain the cummin for two columns for each group, group by two columns const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) let grp = df.groupby(["A","B"]) -grp.col(["C","D"]).cummin().head().print() -grp.col(["C","D"]).cummin().tail().print() +let grpCol = grp.col(["C","D"]) +grpCol.cumMin().head().print() +grpCol.cumMin().tail().print() ``` {% endtab %} {% endtabs %} diff --git a/api-reference/groupby/groupby.cumProd.md b/api-reference/groupby/groupby.cumProd.md new file mode 100644 index 0000000..fef9f49 --- /dev/null +++ b/api-reference/groupby/groupby.cumProd.md @@ -0,0 +1,221 @@ +--- +description: Obtain the cumulative product per group for each column +--- + +# Groupby.cumProd + +> danfo.Groupby.**cumProd**\(\) \[[source](https://github.com/javascriptdata/danfojs/blob/65f9b3753389b08101d4bb00a2d6488255476aaf/src/danfojs-base/aggregators/groupby.ts#L489)\] + +**Parameters**: None + +**Return**: DataFrame + +**Examples** + +Obtain the cumulative product of a column for each groups, group by one column + +{% tabs %} +{% tab title="Node" %} +```javascript +const dfd = require("danfojs-node") + + +let data ={A: ['foo', 'bar', 'foo', 'bar', + 'foo', 'bar', 'foo', 'foo'], + B: ['one', 'one', 'two', 'three', + 'two', 'two', 'one', 'three'], + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} + +let df = new dfd.DataFrame(data) + +let grp = df.groupby(["A"]) +let grpCol = grp.col(["C"]) +grpCol.cumProd().head().print() +grpCol.cumProd().tail().print() +``` +{% endtab %} +{% endtabs %} + +```text + + Shape: (5,2) + +╔═══╤═══════════════════╤═══════════════════╗ +║ │ A │ C_cumprod ║ +╟───┼───────────────────┼───────────────────╢ +║ 0 │ foo │ 1 ║ +╟───┼───────────────────┼───────────────────╢ +║ 1 │ foo │ 2 ║ +╟───┼───────────────────┼───────────────────╢ +║ 2 │ foo │ 10 ║ +╟───┼───────────────────┼───────────────────╢ +║ 3 │ foo │ 60 ║ +╟───┼───────────────────┼───────────────────╢ +║ 4 │ foo │ 420 ║ +╚═══╧═══════════════════╧═══════════════════╝ + + + Shape: (5,2) + +╔═══╤═══════════════════╤═══════════════════╗ +║ │ A │ C_cumprod ║ +╟───┼───────────────────┼───────────────────╢ +║ 3 │ foo │ 60 ║ +╟───┼───────────────────┼───────────────────╢ +║ 4 │ foo │ 420 ║ +╟───┼───────────────────┼───────────────────╢ +║ 5 │ bar │ 3 ║ +╟───┼───────────────────┼───────────────────╢ +║ 6 │ bar │ 12 ║ +╟───┼───────────────────┼───────────────────╢ +║ 7 │ bar │ 24 ║ +╚═══╧═══════════════════╧═══════════════════╝ +``` + +Obtain the cumProd for two columns for each groups, group by one column + +{% tabs %} +{% tab title="Node" %} +```javascript +const dfd = require("danfojs-node") + + +let data ={'A': ['foo', 'bar', 'foo', 'bar', + 'foo', 'bar', 'foo', 'foo'], + 'B': ['one', 'one', 'two', 'three', + 'two', 'two', 'one', 'three'], + 'C': [1,3,2,4,5,2,6,7], + 'D': [3,2,4,1,5,6,7,8] + } + +let df = new dfd.DataFrame(data) + +let grp = df.groupby(["A"]) +let grpCol = grp.col(["C","D"]) +grpCol.cumProd().print() +``` +{% endtab %} +{% endtabs %} + +```text + +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ A │ C_cumprod │ D_cumprod ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ foo │ 1 │ 3 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ foo │ 2 │ 12 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 2 │ foo │ 10 │ 60 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 3 │ foo │ 60 │ 420 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 4 │ foo │ 420 │ 3360 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 5 │ bar │ 3 │ 2 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 6 │ bar │ 12 │ 2 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 7 │ bar │ 24 │ 12 ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ +``` + +Obtain the cumProd for a column for each group, group by two columns + +{% tabs %} +{% tab title="Node" %} +```javascript +const dfd = require("danfojs-node") + + +let data ={'A': ['foo', 'bar', 'foo', 'bar', + 'foo', 'bar', 'foo', 'foo'], + 'B': ['one', 'one', 'two', 'three', + 'two', 'two', 'one', 'three'], + 'C': [1,3,2,4,5,2,6,7], + 'D': [3,2,4,1,5,6,7,8] + } + +let df = new dfd.DataFrame(data) + +let grp = df.groupby(["A","B"]) +let grpCol = grp.col(["C"]) +grpCol.cumProd().print() + +``` +{% endtab %} +{% endtabs %} + +```text +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ A │ B │ C_cumprod ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ foo │ one │ 1 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ foo │ one │ 6 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 2 │ foo │ two │ 2 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 3 │ foo │ two │ 10 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 4 │ foo │ three │ 7 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 5 │ bar │ one │ 3 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 6 │ bar │ three │ 4 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 7 │ bar │ two │ 2 ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ +``` + +Obtain the cumProd for two columns for each group, group by two columns + +{% tabs %} +{% tab title="Node" %} +```javascript +const dfd = require("danfojs-node") + + +let data ={A: ['foo', 'bar', 'foo', 'bar', + 'foo', 'bar', 'foo', 'foo'], + B: ['one', 'one', 'two', 'three', + 'two', 'two', 'one', 'three'], + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} + +let df = new dfd.DataFrame(data) + +let grp = df.groupby(["A","B"]) +let grpCol = grp.col(["C","D"]) +grpCol.cumProd().print() +``` +{% endtab %} +{% endtabs %} + +```text + +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ A │ B │ C_cumprod │ D_cumprod ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ foo │ one │ 1 │ 3 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ foo │ one │ 6 │ 21 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 2 │ foo │ two │ 2 │ 4 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 3 │ foo │ two │ 10 │ 20 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 4 │ foo │ three │ 7 │ 8 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 5 │ bar │ one │ 3 │ 2 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 6 │ bar │ three │ 4 │ 1 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 7 │ bar │ two │ 2 │ 6 ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ + +``` + diff --git a/api-reference/groupby/groupby.cumSum.md b/api-reference/groupby/groupby.cumSum.md new file mode 100644 index 0000000..440fa31 --- /dev/null +++ b/api-reference/groupby/groupby.cumSum.md @@ -0,0 +1,200 @@ +--- +description: Obtain the cumulative sum per groups for each column +--- + +# Groupby.cumSum + +> danfo.Groupby.**cumSum**() \[[source](https://github.com/javascriptdata/danfojs/blob/0d33e344b80a3ed54c91c9393ac3b583d4b0b1a4/src/danfojs-base/aggregators/groupby.ts#L473)] + +**Parameters**: None + +**Return**: DataFrame + +**Examples** + +Obtain the cumulative sum of a column for each groups, group by one column + +{% tabs %} +{% tab title="Node" %} +```javascript +const dfd = require("danfojs-node") + + +let data ={A: ['foo', 'bar', 'foo', 'bar', + 'foo', 'bar', 'foo', 'foo'], + B: ['one', 'one', 'two', 'three', + 'two', 'two', 'one', 'three'], + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} + +let df = new dfd.DataFrame(data) + +let grp = df.groupby(["A"]) +grp.col(["C"]).cumSum().print() +``` +{% endtab %} +{% endtabs %} + +``` +╔════════════╤═══════════════════╤═══════════════════╗ +║ │ A │ C_cumsum ║ +╟────────────┼───────────────────┼───────────────────╢ +║ 0 │ foo │ 1 ║ +╟────────────┼───────────────────┼───────────────────╢ +║ 1 │ foo │ 3 ║ +╟────────────┼───────────────────┼───────────────────╢ +║ 2 │ foo │ 8 ║ +╟────────────┼───────────────────┼───────────────────╢ +║ 3 │ foo │ 14 ║ +╟────────────┼───────────────────┼───────────────────╢ +║ 4 │ foo │ 21 ║ +╟────────────┼───────────────────┼───────────────────╢ +║ 5 │ bar │ 3 ║ +╟────────────┼───────────────────┼───────────────────╢ +║ 6 │ bar │ 7 ║ +╟────────────┼───────────────────┼───────────────────╢ +║ 7 │ bar │ 9 ║ +╚════════════╧═══════════════════╧═══════════════════╝ + +``` + +Obtain the cumsum for two columns for each group, group by one column + +{% tabs %} +{% tab title="Node" %} +```javascript +const dfd = require("danfojs-node") + + +let data ={A: ['foo', 'bar', 'foo', 'bar', + 'foo', 'bar', 'foo', 'foo'], + B: ['one', 'one', 'two', 'three', + 'two', 'two', 'one', 'three'], + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} + +let df = new dfd.DataFrame(data) + +let grp = df.groupby(["A"]) +grp.col(["C","D"]).cumSum().print() +``` +{% endtab %} +{% endtabs %} + +``` +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ A │ C_cumsum │ D_cumsum ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ foo │ 1 │ 3 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ foo │ 3 │ 7 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 2 │ foo │ 8 │ 12 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 3 │ foo │ 14 │ 19 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 4 │ foo │ 21 │ 27 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 5 │ bar │ 3 │ 2 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 6 │ bar │ 7 │ 3 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 7 │ bar │ 9 │ 9 ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ +``` + +Obtain the cumsum for a column for each group, group by two columns + +{% tabs %} +{% tab title="Node" %} +```javascript +const dfd = require("danfojs-node") + +let data ={A: ['foo', 'bar', 'foo', 'bar', + 'foo', 'bar', 'foo', 'foo'], + B: ['one', 'one', 'two', 'three', + 'two', 'two', 'one', 'three'], + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} + +let df = new dfd.DataFrame(data) + +let grp = df.groupby(["A","B"]) +grp.col(["C"]).cumSum().print() + +``` +{% endtab %} +{% endtabs %} + +``` +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ A │ B │ C_cumsum ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ foo │ one │ 1 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ foo │ one │ 7 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 2 │ foo │ two │ 2 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 3 │ foo │ two │ 7 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 4 │ foo │ three │ 7 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 5 │ bar │ one │ 3 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 6 │ bar │ three │ 4 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 7 │ bar │ two │ 2 ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ + +``` + +Obtain the count for two columns for each group, group by two columns + +{% tabs %} +{% tab title="Node" %} +```javascript +const dfd = require("danfojs-node") + +let data ={A: ['foo', 'bar', 'foo', 'bar', + 'foo', 'bar', 'foo', 'foo'], + B: ['one', 'one', 'two', 'three', + 'two', 'two', 'one', 'three'], + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} + +let df = new dfd.DataFrame(data) + +let grp = df.groupby(["A","B"]) +grp.col(["C","D"]).cumSum().print() +``` +{% endtab %} +{% endtabs %} + +``` +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ A │ B │ C_cumsum │ D_cumsum ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ foo │ one │ 1 │ 3 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ foo │ one │ 7 │ 10 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 2 │ foo │ two │ 2 │ 4 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 3 │ foo │ two │ 7 │ 9 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 4 │ foo │ three │ 7 │ 8 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 5 │ bar │ one │ 3 │ 2 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 6 │ bar │ three │ 4 │ 1 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 7 │ bar │ two │ 2 │ 6 ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ +``` + +**** diff --git a/api-reference/groupby/groupby.cummin.md b/api-reference/groupby/groupby.cummin.md deleted file mode 100644 index 7fd9ed6..0000000 --- a/api-reference/groupby/groupby.cummin.md +++ /dev/null @@ -1,258 +0,0 @@ ---- -description: Obtain the cummulative minimum per groups for each column ---- - -# Groupby.cummin - -> danfo.Groupby.**cummin**\(\) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L297)\] - -**Parameters**: None - -**Return**: DataFrame - -**Examples** - -Obtain the cumulative min of a column for each groups, group by one column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A"]) -grp.col(["C"]).cummin().head().print() -grp.col(["C"]).cummin().tail().print() -``` -{% endtab %} -{% endtabs %} - -```text - - Shape: (5,2) - -╔═══╤═══════════════════╤═══════════════════╗ -║ │ A │ C_cummin ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 1 ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ foo │ 1 ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ foo │ 1 ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ foo │ 1 ║ -╟───┼───────────────────┼───────────────────╢ -║ 4 │ foo │ 1 ║ -╚═══╧═══════════════════╧═══════════════════╝ - - - Shape: (5,2) - -╔═══╤═══════════════════╤═══════════════════╗ -║ │ A │ C_cummin ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ foo │ 1 ║ -╟───┼───────────────────┼───────────────────╢ -║ 4 │ foo │ 1 ║ -╟───┼───────────────────┼───────────────────╢ -║ 5 │ bar │ 3 ║ -╟───┼───────────────────┼───────────────────╢ -║ 6 │ bar │ 3 ║ -╟───┼───────────────────┼───────────────────╢ -║ 7 │ bar │ 2 ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` - -Obtain the cummin for two columns for each group, group by one column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A"]) -grp.col(["C","D"]).cummin().head().print() -grp.col(["C","D"]).cummin().tail().print() -``` -{% endtab %} -{% endtabs %} - -```text - - Shape: (5,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ C_cummin │ D_cummin ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 1 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ 1 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ 1 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ 1 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ 1 │ 3 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (5,3) - -╔════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ C_cummin │ D_cummin ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 11 │ bar │ 3 │ 1 ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 12 │ bar │ 2 │ 1 ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 13 │ bar │ 3 │ 2 ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 14 │ bar │ 3 │ 1 ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 15 │ bar │ 2 │ 1 ║ -╚════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Obtain the cummin for a column for each group, group by two columns - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A","B"]) -grp.col(["C"]).cummin().head().print() -grp.col(["C"]).cummin().tail().print() - -``` -{% endtab %} -{% endtabs %} - -```text - Shape: (5,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_cummin ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ one │ 1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ two │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ two │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ three │ 7 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (5,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_cummin ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ two │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ three │ 7 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 5 │ bar │ one │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 6 │ bar │ two │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 7 │ bar │ three │ 4 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Obtain the cummin for two columns for each group, group by two columns - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A","B"]) -grp.col(["C","D"]).cummin().head().print() -grp.col(["C","D"]).cummin().tail().print() -``` -{% endtab %} -{% endtabs %} - -```text - - Shape: (5,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_cummin │ D_cummin ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 1 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ one │ 1 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ two │ 2 │ 4 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ two │ 2 │ 4 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ three │ 7 │ 8 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (5,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_cummin │ D_cummin ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ two │ 2 │ 4 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ three │ 7 │ 8 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 5 │ bar │ one │ 3 │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 6 │ bar │ two │ 2 │ 6 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 7 │ bar │ three │ 4 │ 1 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - diff --git a/api-reference/groupby/groupby.cumprod.md b/api-reference/groupby/groupby.cumprod.md deleted file mode 100644 index af46123..0000000 --- a/api-reference/groupby/groupby.cumprod.md +++ /dev/null @@ -1,258 +0,0 @@ ---- -description: Obtain the cumulative product per group for each column ---- - -# Groupby.cumprod - -> danfo.Groupby.**cumprod**\(\) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L291)\] - -**Parameters**: None - -**Return**: DataFrame - -**Examples** - -Obtain the cumulative product of a column for each groups, group by one column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A"]) -grp.col(["C"]).cumprod().head().print() -grp.col(["C"]).cumprod().tail().print() -``` -{% endtab %} -{% endtabs %} - -```text - - Shape: (5,2) - -╔═══╤═══════════════════╤═══════════════════╗ -║ │ A │ C_cumprod ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 1 ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ foo │ 2 ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ foo │ 10 ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ foo │ 60 ║ -╟───┼───────────────────┼───────────────────╢ -║ 4 │ foo │ 420 ║ -╚═══╧═══════════════════╧═══════════════════╝ - - - Shape: (5,2) - -╔═══╤═══════════════════╤═══════════════════╗ -║ │ A │ C_cumprod ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ foo │ 60 ║ -╟───┼───────────────────┼───────────────────╢ -║ 4 │ foo │ 420 ║ -╟───┼───────────────────┼───────────────────╢ -║ 5 │ bar │ 3 ║ -╟───┼───────────────────┼───────────────────╢ -║ 6 │ bar │ 12 ║ -╟───┼───────────────────┼───────────────────╢ -║ 7 │ bar │ 24 ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` - -Obtain the cumprod for two columns for each groups, group by one column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A"]) -grp.col(["C","D"]).cumprod().head().print() -grp.col(["C","D"]).cumprod().tail().print() -``` -{% endtab %} -{% endtabs %} - -```text - -Shape: (5,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ C_cumprod │ D_cumprod ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 1 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ 2 │ 12 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ 10 │ 60 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ 60 │ 420 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ 420 │ 3360 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (5,3) - -╔════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ C_cumprod │ D_cumprod ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 11 │ bar │ 12 │ 2 ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 12 │ bar │ 24 │ 12 ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 13 │ bar │ 3 │ 2 ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 14 │ bar │ 12 │ 2 ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 15 │ bar │ 24 │ 12 ║ -╚════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Obtain the cumprod for a column for each group, group by two columns - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A","B"]) -grp.col(["C"]).cumprod().head().print() -grp.col(["C"]).cumprod().tail().print() - -``` -{% endtab %} -{% endtabs %} - -```text - Shape: (5,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_cumprod ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ one │ 6 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ two │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ two │ 10 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ three │ 7 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (5,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_cumprod ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ two │ 10 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ three │ 7 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 5 │ bar │ one │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 6 │ bar │ two │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 7 │ bar │ three │ 4 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Obtain the cumprod for two columns for each group, group by two columns - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A","B"]) -grp.col(["C","D"]).cumprod().head().print() -grp.col(["C","D"]).cumprod().tail().print() -``` -{% endtab %} -{% endtabs %} - -```text - - Shape: (5,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_cumprod │ D_cumprod ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 1 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ one │ 6 │ 21 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ two │ 2 │ 4 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ two │ 10 │ 20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ three │ 7 │ 8 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (5,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_cumprod │ D_cumprod ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ two │ 10 │ 20 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ three │ 7 │ 8 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 5 │ bar │ one │ 3 │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 6 │ bar │ two │ 2 │ 6 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 7 │ bar │ three │ 4 │ 1 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - diff --git a/api-reference/groupby/groupby.cumsum.md b/api-reference/groupby/groupby.cumsum.md deleted file mode 100644 index 3b2b0e6..0000000 --- a/api-reference/groupby/groupby.cumsum.md +++ /dev/null @@ -1,259 +0,0 @@ ---- -description: Obtain the cumulative sum per groups for each column ---- - -# Groupby.cumsum - -> danfo.Groupby.**cumsum**() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L280)] - -**Parameters**: None - -**Return**: DataFrame - -**Examples** - -Obtain the cumulative sum of a column for each groups, group by one column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A"]) -grp.col(["C"]).cumsum().head().print() -grp.col(["C"]).cumsum().tail().print() -``` -{% endtab %} -{% endtabs %} - -``` - -Shape: (5,2) - -╔═══╤═══════════════════╤═══════════════════╗ -║ │ A │ C_cumsum ║ -╟───┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 1 ║ -╟───┼───────────────────┼───────────────────╢ -║ 1 │ foo │ 3 ║ -╟───┼───────────────────┼───────────────────╢ -║ 2 │ foo │ 8 ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ foo │ 14 ║ -╟───┼───────────────────┼───────────────────╢ -║ 4 │ foo │ 21 ║ -╚═══╧═══════════════════╧═══════════════════╝ - - - Shape: (5,2) - -╔═══╤═══════════════════╤═══════════════════╗ -║ │ A │ C_cumsum ║ -╟───┼───────────────────┼───────────────────╢ -║ 3 │ foo │ 14 ║ -╟───┼───────────────────┼───────────────────╢ -║ 4 │ foo │ 21 ║ -╟───┼───────────────────┼───────────────────╢ -║ 5 │ bar │ 3 ║ -╟───┼───────────────────┼───────────────────╢ -║ 6 │ bar │ 7 ║ -╟───┼───────────────────┼───────────────────╢ -║ 7 │ bar │ 9 ║ -╚═══╧═══════════════════╧═══════════════════╝ -``` - -Obtain the cumsum for two columns for each group, group by one column - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A"]) -grp.col(["C","D"]).cumsum().head().print() -grp.col(["C","D"]).cumsum().tail().print() -``` -{% endtab %} -{% endtabs %} - -``` - - Shape: (5,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ C_cumsum │ D_cumsum ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ 1 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ 3 │ 7 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ 8 │ 12 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ 14 │ 19 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ 21 │ 27 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (5,3) - -╔════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ C_cumsum │ D_cumsum ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 11 │ bar │ 7 │ 3 ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 12 │ bar │ 9 │ 9 ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 13 │ bar │ 3 │ 2 ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 14 │ bar │ 7 │ 3 ║ -╟────┼───────────────────┼───────────────────┼───────────────────╢ -║ 15 │ bar │ 9 │ 9 ║ -╚════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Obtain the cumsum for a column for each group, group by two columns - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A","B"]) -grp.col(["C"]).cumsum().head().print() -grp.col(["C"]).cumsum().tail().print() - -``` -{% endtab %} -{% endtabs %} - -``` - Shape: (5,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_cumsum ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ one │ 7 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ two │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ two │ 7 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ three │ 7 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (5,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_cumsum ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ two │ 7 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ three │ 7 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 5 │ bar │ one │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 6 │ bar │ two │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 7 │ bar │ three │ 4 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -Obtain the count for two columns for each group, group by two columns - -{% tabs %} -{% tab title="Node" %} -```javascript -const dfd = require("danfojs-node") - - -let data ={'A': ['foo', 'bar', 'foo', 'bar', - 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', - 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } - -let df = new dfd.DataFrame(data) - -let grp = df.groupby(["A","B"]) -grp.col(["C","D"]).cumsum().head().print() -grp.col(["C","D"]).cumsum().tail().print() -``` -{% endtab %} -{% endtabs %} - -``` - - Shape: (5,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_cumsum │ D_cumsum ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 1 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ one │ 7 │ 10 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ two │ 2 │ 4 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ two │ 7 │ 9 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ three │ 7 │ 8 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - - - Shape: (5,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_cumsum │ D_cumsum ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ foo │ two │ 7 │ 9 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ foo │ three │ 7 │ 8 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 5 │ bar │ one │ 3 │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 6 │ bar │ two │ 2 │ 6 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 7 │ bar │ three │ 4 │ 1 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -``` - -**** diff --git a/api-reference/groupby/groupby.first.md b/api-reference/groupby/groupby.first.md new file mode 100644 index 0000000..b1bcd26 --- /dev/null +++ b/api-reference/groupby/groupby.first.md @@ -0,0 +1,89 @@ +--- +description: Obtain the first row of each groups +--- + +# Groupby.first + +> danfo.Groupby.first \[[source](https://github.com/javascriptdata/danfojs/blob/9bfda6dcb6b2b620591ec7b3340d35e3f801c8ab/src/danfojs-base/aggregators/groupby.ts#L615)\] + +**Parameters**: None + +**Return**: DataFrame + +**Examples** + +Obtain the first row of each group for dataframe grouped by one column + +{% tabs %} +{% tab title="Node" %} +```javascript +const dfd = require("danfojs-node") + +let data ={A: ['foo', 'bar', 'foo', 'bar', + 'foo', 'bar', 'foo', 'foo'], + B: ['one', 'one', 'two', 'three', + 'two', 'two', 'one', 'three'], + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] + } + +let df = new dfd.DataFrame(data) + + +let grp = df.groupby(["A"]) +grp.first().print() +``` +{% endtab %} +{% endtabs %} + +``` +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ A_Group │ A │ B │ C │ D ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ foo │ foo │ one │ 1 │ 3 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ bar │ bar │ one │ 3 │ 2 ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ +``` + +Obtain the number of groups in dataframe grouped by two columns + +{% tabs %} +{% tab title="Node" %} +```javascript +const dfd = require("danfojs-node") + +let data ={A: ['foo', 'bar', 'foo', 'bar', + 'foo', 'bar', 'foo', 'foo'], + B: ['one', 'one', 'two', 'three', + 'two', 'two', 'one', 'three'], + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} + +let df = new dfd.DataFrame(data) +let grp = df.groupby(["A","B"]) +grp.first().print() +``` +{% endtab %} +{% endtabs %} + +``` +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ A_Group │ B_Group │ A │ B │ C │ D ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ foo │ one │ foo │ one │ 1 │ 3 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ foo │ two │ foo │ two │ 2 │ 4 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 2 │ foo │ three │ foo │ three │ 7 │ 8 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 3 │ bar │ one │ bar │ one │ 3 │ 2 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 4 │ bar │ three │ bar │ three │ 4 │ 1 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 5 │ bar │ two │ bar │ two │ 2 │ 6 ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ +``` + +**** \ No newline at end of file diff --git a/api-reference-v1-stable/groupby/groupby.get_groups.md b/api-reference/groupby/groupby.getGroup.md similarity index 90% rename from api-reference-v1-stable/groupby/groupby.get_groups.md rename to api-reference/groupby/groupby.getGroup.md index 0cdf912..4fed78e 100644 --- a/api-reference-v1-stable/groupby/groupby.get_groups.md +++ b/api-reference/groupby/groupby.getGroup.md @@ -2,9 +2,9 @@ description: Obtain the data for each element of the groupby column --- -# Groupby.get\_groups +# Groupby.getGroup -> danfo.Groupby.get\_groups\(key\) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L313)\] +> danfo.Groupby.getGroup(key\) \[[source](https://github.com/javascriptdata/danfojs/blob/0d33e344b80a3ed54c91c9393ac3b583d4b0b1a4/src/danfojs-base/aggregators/groupby.ts#L523)\] | Parameters | Type | Description | default | | :--- | :--- | :--- | :--- | @@ -21,22 +21,22 @@ Group the dataframe by column A and obtain the group belonging to the values in ```javascript const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) let grp = df.groupby(["A"]) -grp.get_groups(["foo"]).print() +grp.getGroup(["foo"]).print() -grp.get_groups(["bar"]).print() +grp.getGroup(["bar"]).print() ``` {% endtab %} {% endtabs %} @@ -74,35 +74,35 @@ grp.get_groups(["bar"]).print() ╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ ``` -Group dataframe by two columns and obtain their groups. Since the dataframe is grouped by two columns we most specify two keys in the get\_groups belonging to these two columns +Group dataframe by two columns and obtain their groups. Since the dataframe is grouped by two columns we most specify two keys in the getGroups belonging to these two columns {% tabs %} {% tab title="Node" %} ```javascript const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) let grp = df.groupby(["A","B"]) -grp.get_groups(["foo","one"]).print() +grp.getGroup(["foo","one"]).print() -grp.get_groups(["bar","one"]).print() +grp.getGroup(["bar","one"]).print() ``` {% endtab %} {% endtabs %} ```text -//get_groups(["foo","one"] +//getGroup(["foo","one"] Shape: (2,4) @@ -115,7 +115,7 @@ grp.get_groups(["bar","one"]).print() ║ 1 │ foo │ one │ 6 │ 7 ║ ╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -//get_groups(["bar","one"]) +//getGroup(["bar","one"]) Shape: (1,4) diff --git a/api-reference/groupby/groupby.get_groups.md b/api-reference/groupby/groupby.get_groups.md index 0cdf912..4450e0a 100644 --- a/api-reference/groupby/groupby.get_groups.md +++ b/api-reference/groupby/groupby.get_groups.md @@ -2,13 +2,13 @@ description: Obtain the data for each element of the groupby column --- -# Groupby.get\_groups +# Groupby.getGroups -> danfo.Groupby.get\_groups\(key\) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L313)\] +> danfo.Groupby.getGroups(key) \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L313)] -| Parameters | Type | Description | default | -| :--- | :--- | :--- | :--- | -| key | Array | element of the groupby column | | +| Parameters | Type | Description | default | +| ---------- | ----- | ----------------------------- | ------- | +| key | Array | element of the groupby column | | **Returns**: DataFrame @@ -34,14 +34,14 @@ let df = new dfd.DataFrame(data) let grp = df.groupby(["A"]) -grp.get_groups(["foo"]).print() +grp.getGroup(["foo"]).print() -grp.get_groups(["bar"]).print() +grp.getGroup(["bar"]).print() ``` {% endtab %} {% endtabs %} -```text +``` //get groups for key "foo" Shape: (5,4) @@ -74,7 +74,7 @@ grp.get_groups(["bar"]).print() ╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ ``` -Group dataframe by two columns and obtain their groups. Since the dataframe is grouped by two columns we most specify two keys in the get\_groups belonging to these two columns +Group dataframe by two columns and obtain their groups. Since the dataframe is grouped by two columns we most specify two keys in the getGroups belonging to these two columns {% tabs %} {% tab title="Node" %} @@ -94,15 +94,15 @@ let df = new dfd.DataFrame(data) let grp = df.groupby(["A","B"]) -grp.get_groups(["foo","one"]).print() +grp.getGroup(["foo","one"]).print() -grp.get_groups(["bar","one"]).print() +grp.getGroup(["bar","one"]).print() ``` {% endtab %} {% endtabs %} -```text -//get_groups(["foo","one"] +``` +//getGroup(["foo","one"] Shape: (2,4) @@ -115,7 +115,7 @@ grp.get_groups(["bar","one"]).print() ║ 1 │ foo │ one │ 6 │ 7 ║ ╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ -//get_groups(["bar","one"]) +//getGroup(["bar","one"]) Shape: (1,4) @@ -126,4 +126,3 @@ grp.get_groups(["bar","one"]).print() ║ 0 │ bar │ one │ 3 │ 2 ║ ╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ ``` - diff --git a/api-reference/groupby/groupby.groups.md b/api-reference/groupby/groupby.groups.md new file mode 100644 index 0000000..a6208b3 --- /dev/null +++ b/api-reference/groupby/groupby.groups.md @@ -0,0 +1,99 @@ +--- +description: Obtain groupby internal data object +--- + +# Groupby.ngroups + +> danfo.Groupby.groups \[[source](https://github.com/javascriptdata/danfojs/blob/9bfda6dcb6b2b620591ec7b3340d35e3f801c8ab/src/danfojs-base/aggregators/groupby.ts#L598)\] + +**Parameters**: None + +**Return**: Object + +**Examples** + +Obtain the group object for grouped by single column dataframe + +{% tabs %} +{% tab title="Node" %} +```javascript +const dfd = require("danfojs-node") + +let data ={A: ['foo', 'bar', 'foo', 'bar', + 'foo', 'bar', 'foo', 'foo'], + B: ['one', 'one', 'two', 'three', + 'two', 'two', 'one', 'three'], + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] + } + +let df = new dfd.DataFrame(data) + + +let grp = df.groupby(["A"]) +console.log(grp.groups) +``` +{% endtab %} +{% endtabs %} + +``` +{ + foo: { + A: [ 'foo', 'foo', 'foo', 'foo', 'foo' ], + B: [ 'one', 'two', 'two', 'one', 'three' ], + C: [ 1, 2, 5, 6, 7 ], + D: [ 3, 4, 5, 7, 8 ] + }, + bar: { + A: [ 'bar', 'bar', 'bar' ], + B: [ 'one', 'three', 'two' ], + C: [ 3, 4, 2 ], + D: [ 2, 1, 6 ] + } +} +``` + +Obtain the group object for grouped by two column dataframe + +{% tabs %} +{% tab title="Node" %} +```javascript +const dfd = require("danfojs-node") + +let data ={A: ['foo', 'bar', 'foo', 'bar', + 'foo', 'bar', 'foo', 'foo'], + B: ['one', 'one', 'two', 'three', + 'two', 'two', 'one', 'three'], + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} + +let df = new dfd.DataFrame(data) +let grp = df.groupby(["A","B"]) +console.log(grp.groups) +``` +{% endtab %} +{% endtabs %} + +``` +{ + 'foo-one': { + A: [ 'foo', 'foo' ], + B: [ 'one', 'one' ], + C: [ 1, 6 ], + D: [ 3, 7 ] + }, + 'bar-one': { A: [ 'bar' ], B: [ 'one' ], C: [ 3 ], D: [ 2 ] }, + 'foo-two': { + A: [ 'foo', 'foo' ], + B: [ 'two', 'two' ], + C: [ 2, 5 ], + D: [ 4, 5 ] + }, + 'bar-three': { A: [ 'bar' ], B: [ 'three' ], C: [ 4 ], D: [ 1 ] }, + 'bar-two': { A: [ 'bar' ], B: [ 'two' ], C: [ 2 ], D: [ 6 ] }, + 'foo-three': { A: [ 'foo' ], B: [ 'three' ], C: [ 7 ], D: [ 8 ] } +} +``` + +**** \ No newline at end of file diff --git a/api-reference/groupby/groupby.last.md b/api-reference/groupby/groupby.last.md new file mode 100644 index 0000000..51174bf --- /dev/null +++ b/api-reference/groupby/groupby.last.md @@ -0,0 +1,87 @@ +--- +description: Obtain the last row of each groups +--- + +# Groupby.last + +> danfo.Groupby.last \[[source](https://github.com/javascriptdata/danfojs/blob/9bfda6dcb6b2b620591ec7b3340d35e3f801c8ab/src/danfojs-base/aggregators/groupby.ts#L625)\] + +**Parameters**: None + +**Return**: DataFrame + +**Examples** + +Obtain the last row of each group for dataframe grouped by one column + +{% tabs %} +{% tab title="Node" %} +```javascript +const dfd = require("danfojs-node") + +let data ={A: ['foo', 'bar', 'foo', 'bar', + 'foo', 'bar', 'foo', 'foo'], + B: ['one', 'one', 'two', 'three', + 'two', 'two', 'one', 'three'], + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] + } + +let df = new dfd.DataFrame(data) +let grp = df.groupby(["A"]) +grp.last().print() +``` +{% endtab %} +{% endtabs %} + +``` +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ A_Group │ A │ B │ C │ D ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ foo │ foo │ three │ 7 │ 8 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ bar │ bar │ two │ 2 │ 6 ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ +``` + +Obtain the number of groups in dataframe grouped by two columns + +{% tabs %} +{% tab title="Node" %} +```javascript +const dfd = require("danfojs-node") + +let data ={A: ['foo', 'bar', 'foo', 'bar', + 'foo', 'bar', 'foo', 'foo'], + B: ['one', 'one', 'two', 'three', + 'two', 'two', 'one', 'three'], + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} + +let df = new dfd.DataFrame(data) +let grp = df.groupby(["A","B"]) +grp.last().print() +``` +{% endtab %} +{% endtabs %} + +``` +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ A_Group │ B_Group │ A │ B │ C │ D ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ foo │ one │ foo │ one │ 6 │ 7 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ foo │ two │ foo │ two │ 5 │ 5 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 2 │ foo │ three │ foo │ three │ 7 │ 8 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 3 │ bar │ one │ bar │ one │ 3 │ 2 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 4 │ bar │ three │ bar │ three │ 4 │ 1 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 5 │ bar │ two │ bar │ two │ 2 │ 6 ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ +``` + +**** \ No newline at end of file diff --git a/api-reference/groupby/groupby.max.md b/api-reference/groupby/groupby.max.md index 43470f6..98c2c55 100644 --- a/api-reference/groupby/groupby.max.md +++ b/api-reference/groupby/groupby.max.md @@ -4,7 +4,7 @@ description: Obtain the maximum value of columns per groups # Groupby.max -> danfo.Groupby.max() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L309)] +> danfo.Groupby.max() \[[source](https://github.com/javascriptdata/danfojs/blob/0d33e344b80a3ed54c91c9393ac3b583d4b0b1a4/src/danfojs-base/aggregators/groupby.ts#L506)] **Parameters:** None @@ -19,13 +19,13 @@ Obtain the maximum value for a column for each group, group by one column ```javascript const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) @@ -56,13 +56,13 @@ Obtain the maximum value for two columns for each group, group by one column const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) @@ -92,13 +92,13 @@ Obtain the maximum value for a column for each group, group by two columns ```javascript const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) @@ -134,13 +134,13 @@ Obtain the maximum value for two columns for each group, group by two columns ```javascript const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) diff --git a/api-reference/groupby/groupby.mean.md b/api-reference/groupby/groupby.mean.md index add6958..c411bba 100644 --- a/api-reference/groupby/groupby.mean.md +++ b/api-reference/groupby/groupby.mean.md @@ -4,7 +4,7 @@ description: Obtain the mean per groups for each column(s) # Groupby.mean -> danfo.Series.mean() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L274)] +> danfo.Series.mean() \[[source](https://github.com/javascriptdata/danfojs/blob/0d33e344b80a3ed54c91c9393ac3b583d4b0b1a4/src/danfojs-base/aggregators/groupby.ts#L464)] **Parameters**: None @@ -19,13 +19,13 @@ Obtain the mean of a column for each group, group by one column ```javascript const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) @@ -57,13 +57,13 @@ Obtain the mean for two columns for each group, group by one column const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) @@ -93,13 +93,13 @@ Obtain the mean for a column for each group, group by two columns ```javascript const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) @@ -135,17 +135,15 @@ Obtain the mean for two columns for each group, group by two columns ```javascript const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) - - let grp = df.groupby(["A","B"]) grp.col(["C","D"]).mean().print() ``` diff --git a/api-reference/groupby/groupby.min.md b/api-reference/groupby/groupby.min.md index 0151e64..f74be86 100644 --- a/api-reference/groupby/groupby.min.md +++ b/api-reference/groupby/groupby.min.md @@ -4,7 +4,7 @@ description: Obtain the minimum value per groups for a coumn(s) # Groupby.min -> danfo.Groupby.min() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L315)] +> danfo.Groupby.min() \[[source](https://github.com/javascriptdata/danfojs/blob/9bfda6dcb6b2b620591ec7b3340d35e3f801c8ab/src/danfojs-base/aggregators/groupby.ts#L514)] **Parameters**: None @@ -19,17 +19,16 @@ Obtain the minimum value for a column for each group, group by one column ```javascript const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) - let grp = df.groupby(["A"]) grp.col(["C"]).min().print() ``` @@ -55,17 +54,15 @@ Obtain the minimum value for two columns for each group, group by one column ```javascript const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) - - let grp = df.groupby(["A"]) grp.col(["C","D"]).min().print() ``` @@ -91,17 +88,15 @@ Obtain the maximum value for a column for each group, group by two columns ```javascript const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) - - let grp = df.groupby(["A","B"]) grp.col(["C"]).min().print() ``` @@ -109,21 +104,21 @@ grp.col(["C"]).min().print() {% endtabs %} ``` - Shape: (5,3) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_min ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 1 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ two │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ three │ 7 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ bar │ one │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ bar │ two │ 2 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╝ +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ A │ B │ C_min ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ foo │ one │ 1 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ foo │ two │ 2 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 2 │ foo │ three │ 7 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 3 │ bar │ one │ 3 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 4 │ bar │ three │ 4 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 5 │ bar │ two │ 2 ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ ``` Obtain the maximum value for two columns for each group, group by two columns @@ -133,17 +128,15 @@ Obtain the maximum value for two columns for each group, group by two columns ```javascript const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) - - let grp = df.groupby(["A","B"]) grp.col(["C","D"]).min().print() ``` @@ -151,21 +144,21 @@ grp.col(["C","D"]).min().print() {% endtabs %} ``` - Shape: (5,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_min │ D_min ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 1 │ 3 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ two │ 2 │ 4 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ three │ 7 │ 8 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ bar │ one │ 3 │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ bar │ two │ 2 │ 6 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ A │ B │ C_min │ D_min ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ foo │ one │ 1 │ 3 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ foo │ two │ 2 │ 4 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 2 │ foo │ three │ 7 │ 8 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 3 │ bar │ one │ 3 │ 2 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 4 │ bar │ three │ 4 │ 1 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 5 │ bar │ two │ 2 │ 6 ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ ``` **** diff --git a/api-reference/groupby/groupby.ngroups.md b/api-reference/groupby/groupby.ngroups.md new file mode 100644 index 0000000..951c0d7 --- /dev/null +++ b/api-reference/groupby/groupby.ngroups.md @@ -0,0 +1,69 @@ +--- +description: Obtain the number of groups +--- + +# Groupby.ngroups + +> danfo.Groupby.ngroups \[[source](https://github.com/javascriptdata/danfojs/blob/9bfda6dcb6b2b620591ec7b3340d35e3f801c8ab/src/danfojs-base/aggregators/groupby.ts#L598)\] + +**Parameters**: None + +**Return**: Number + +**Examples** + +Obtain the number of groups in a dataframe grouped by one column + +{% tabs %} +{% tab title="Node" %} +```javascript +const dfd = require("danfojs-node") + +let data ={A: ['foo', 'bar', 'foo', 'bar', + 'foo', 'bar', 'foo', 'foo'], + B: ['one', 'one', 'two', 'three', + 'two', 'two', 'one', 'three'], + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] + } + +let df = new dfd.DataFrame(data) + + +let grp = df.groupby(["A"]) +console.log(grp.ngroups) +``` +{% endtab %} +{% endtabs %} + +``` +2 +``` + +Obtain the number of groups in dataframe grouped by two columns + +{% tabs %} +{% tab title="Node" %} +```javascript +const dfd = require("danfojs-node") + +let data ={A: ['foo', 'bar', 'foo', 'bar', + 'foo', 'bar', 'foo', 'foo'], + B: ['one', 'one', 'two', 'three', + 'two', 'two', 'one', 'three'], + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} + +let df = new dfd.DataFrame(data) +let grp = df.groupby(["A","B"]) +console.log(grp.ngroups) +``` +{% endtab %} +{% endtabs %} + +``` +6 +``` + +**** \ No newline at end of file diff --git a/api-reference-v1-stable/dataframe/dataframe.reset_index.md b/api-reference/groupby/groupby.size.md similarity index 50% rename from api-reference-v1-stable/dataframe/dataframe.reset_index.md rename to api-reference/groupby/groupby.size.md index ddee8e0..a4ae97a 100644 --- a/api-reference-v1-stable/dataframe/dataframe.reset_index.md +++ b/api-reference/groupby/groupby.size.md @@ -1,73 +1,87 @@ --- -description: Reset the index of the DataFrame, and use the default one instead. +description: Obtain the last row of each groups --- -# DataFrame.reset\_index +# Groupby.last -danfo.DataFrame.**reset\_index**(options) \[[source](https://github.com/opensource9ja/danfojs/blob/cf5c7ae3a009458e61eedd18d9c9b5b6b10d5276/danfojs/src/core/frame.js#L125)] +> danfo.Groupby.last \[[source](https://github.com/javascriptdata/danfojs/blob/9bfda6dcb6b2b620591ec7b3340d35e3f801c8ab/src/danfojs-base/aggregators/groupby.ts#L635)\] -| Parameters | Type | Description | Default | -| ---------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------- | -| options | Object |

{

inplace: sBoolean indicating whether to perform the operation inplace or not. Defaults to false

}

| {inplace: false} | +**Parameters**: None -**Returns:** +**Return**: DataFrame - **** return **DataFrame** +**Examples** -## **Examples** +Obtain the size of each group for dataframe grouped by one column {% tabs %} {% tab title="Node" %} ```javascript const dfd = require("danfojs-node") -let data = { - "A": [-20, 30, 47.3], - "B": [34, 5, 6], - "C": [20, 3, 30] -} +let data ={A: ['foo', 'bar', 'foo', 'bar', + 'foo', 'bar', 'foo', 'foo'], + B: ['one', 'one', 'two', 'three', + 'two', 'two', 'one', 'three'], + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] + } + +let df = new dfd.DataFrame(data) +let grp = df.groupby(["A"]) +grp.size().print() +``` +{% endtab %} +{% endtabs %} +``` +╔════════════╤═══════════════════╤═══════════════════╗ +║ │ A_Group │ applyOps ║ +╟────────────┼───────────────────┼───────────────────╢ +║ 0 │ foo │ 5 ║ +╟────────────┼───────────────────┼───────────────────╢ +║ 1 │ bar │ 3 ║ +╚════════════╧═══════════════════╧═══════════════════╝ +``` -let df = new dfd.DataFrame(data, { index: ["a", "b", "c"] }) -df.print() +Obtain the size of each group in dataframe grouped by two columns -df.reset_index({ inplace: true }) //inplace -//df = df.reset_index() //not in inplace +{% tabs %} +{% tab title="Node" %} +```javascript +const dfd = require("danfojs-node") -df.print() -``` -{% endtab %} +let data ={A: ['foo', 'bar', 'foo', 'bar', + 'foo', 'bar', 'foo', 'foo'], + B: ['one', 'one', 'two', 'three', + 'two', 'two', 'one', 'three'], + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} -{% tab title="Browser" %} -``` +let df = new dfd.DataFrame(data) +let grp = df.groupby(["A","B"]) +grp.size().print() ``` {% endtab %} {% endtabs %} -{% tabs %} -{% tab title="Output" %} ``` - ╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ +║ │ A_Group │ B_Group │ applyOps ║ ╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ a │ -20 │ 34 │ 20 ║ +║ 0 │ foo │ one │ 2 ║ ╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ b │ 30 │ 5 │ 3 ║ +║ 1 │ foo │ two │ 2 ║ ╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ c │ 47.3 │ 6 │ 30 ║ -╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - -╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C ║ +║ 2 │ foo │ three │ 1 ║ ╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ -20 │ 34 │ 20 ║ +║ 3 │ bar │ one │ 1 ║ ╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 30 │ 5 │ 3 ║ +║ 4 │ bar │ three │ 1 ║ ╟────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 47.3 │ 6 │ 30 ║ +║ 5 │ bar │ two │ 1 ║ ╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - ``` -{% endtab %} -{% endtabs %} + +**** \ No newline at end of file diff --git a/api-reference/groupby/groupby.std.md b/api-reference/groupby/groupby.std.md index c792a8e..f0d1516 100644 --- a/api-reference/groupby/groupby.std.md +++ b/api-reference/groupby/groupby.std.md @@ -4,7 +4,7 @@ description: Obtain the standard deviation per groups for specified columns # Groupby.std -> danfo.Groupby.**std**() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L262)] +> danfo.Groupby.**std**() \[[source](https://github.com/javascriptdata/danfojs/blob/9bfda6dcb6b2b620591ec7b3340d35e3f801c8ab/src/danfojs-base/aggregators/groupby.ts#L448)] **Parameters**: None @@ -20,17 +20,15 @@ Obtain the standard deviation of a column for each group, group by one column const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) - - let grp = df.groupby(["A"]) grp.col(["C"]).std().print() ``` @@ -58,13 +56,13 @@ Obtain the std for two columns for each group, group by one column const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) @@ -94,13 +92,13 @@ Obtain the std for a column for each group, group by two columns const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) @@ -137,13 +135,13 @@ Obtain the std for two columns for each group, group by two columns const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) diff --git a/api-reference/groupby/groupby.sum.md b/api-reference/groupby/groupby.sum.md index f6f2900..6ad83df 100644 --- a/api-reference/groupby/groupby.sum.md +++ b/api-reference/groupby/groupby.sum.md @@ -4,7 +4,7 @@ description: Obtain the sum per groups for columns # Groupby.sum -> danfo.Groupby.sum() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L256)] +> danfo.Groupby.sum() \[[source](https://github.com/javascriptdata/danfojs/blob/9bfda6dcb6b2b620591ec7b3340d35e3f801c8ab/src/danfojs-base/aggregators/groupby.ts#L440)] **Parameters**: None @@ -19,17 +19,16 @@ Obtain the sum of a column for each group, group by one column ```javascript const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) - let grp = df.groupby(["A"]) grp.col(["C"]).sum().print() ``` @@ -38,8 +37,6 @@ grp.col(["C"]).sum().print() ``` - Shape: (2,2) - ╔═══╤═══════════════════╤═══════════════════╗ ║ │ A │ C_sum ║ ╟───┼───────────────────┼───────────────────╢ @@ -56,17 +53,16 @@ Obtain the sum for two columns for each group, group by one column ```javascript const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) - let grp = df.groupby(["A"]) grp.col(["C","D"]).sum().print() ``` @@ -74,8 +70,6 @@ grp.col(["C","D"]).sum().print() {% endtabs %} ``` - Shape: (2,3) - ╔═══╤═══════════════════╤═══════════════════╤═══════════════════╗ ║ │ A │ C_sum │ D_sum ║ ╟───┼───────────────────┼───────────────────┼───────────────────╢ @@ -92,17 +86,16 @@ Obtain the sum for a column for each group, group by two columns ```javascript const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) - let grp = df.groupby(["A","B"]) grp.col(["C"]).sum().print() ``` @@ -134,17 +127,16 @@ Obtain the sum for two columns for each group, group by two columns ```javascript const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) - let grp = df.groupby(["A","B"]) grp.col(["C","D"]).sum().print() ``` @@ -152,21 +144,21 @@ grp.col(["C","D"]).sum().print() {% endtabs %} ``` - Shape: (5,4) - -╔═══╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ -║ │ A │ B │ C_sum │ D_sum ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ foo │ one │ 7 │ 10 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ foo │ two │ 7 │ 9 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ foo │ three │ 7 │ 8 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ bar │ one │ 3 │ 2 ║ -╟───┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 4 │ bar │ two │ 2 │ 6 ║ -╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ +╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ +║ │ A │ B │ C_sum │ D_sum ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 0 │ foo │ one │ 7 │ 10 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 1 │ foo │ two │ 7 │ 9 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 2 │ foo │ three │ 7 │ 8 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 3 │ bar │ one │ 3 │ 2 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 4 │ bar │ three │ 4 │ 1 ║ +╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ +║ 5 │ bar │ two │ 2 │ 6 ║ +╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ ``` **** diff --git a/api-reference/groupby/groupby.var.md b/api-reference/groupby/groupby.var.md index 373109f..08a9d97 100644 --- a/api-reference/groupby/groupby.var.md +++ b/api-reference/groupby/groupby.var.md @@ -4,7 +4,7 @@ description: Obtain the variance per groups for a specified column # Groupby.var -> danfo.Groupby.**var**() \[[source](https://github.com/opensource9ja/danfojs/blob/master/danfojs/src/core/groupby.js#L268)] +> danfo.Groupby.**var**() \[[source](https://github.com/javascriptdata/danfojs/blob/9bfda6dcb6b2b620591ec7b3340d35e3f801c8ab/src/danfojs-base/aggregators/groupby.ts#L456)] **Parameters**: None @@ -20,17 +20,16 @@ Obtain the variance of a column for each group, group by one column const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) - let grp = df.groupby(["A"]) grp.col(["C"]).var().print() ``` @@ -58,13 +57,13 @@ Obtain the var for two columns for each group, group by one column const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) @@ -94,13 +93,13 @@ Obtain the var for a column for each group, group by two columns const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) @@ -137,13 +136,13 @@ Obtain the var for two columns for each group, group by two columns const dfd = require("danfojs-node") -let data ={'A': ['foo', 'bar', 'foo', 'bar', +let data ={A: ['foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'foo'], - 'B': ['one', 'one', 'two', 'three', + B: ['one', 'one', 'two', 'three', 'two', 'two', 'one', 'three'], - 'C': [1,3,2,4,5,2,6,7], - 'D': [3,2,4,1,5,6,7,8] - } + C: [1,3,2,4,5,2,6,7], + D: [3,2,4,1,5,6,7,8] +} let df = new dfd.DataFrame(data) diff --git a/api-reference/input-output/README.md b/api-reference/input-output/README.md index e86d5de..310be54 100644 --- a/api-reference/input-output/README.md +++ b/api-reference/input-output/README.md @@ -8,11 +8,11 @@ description: Functions for reading tabular/structured data into DataFrame/Series | \`\` | | | ----------------------------------- | -------------------------------------------------------- | -| [`read_csv`](danfo.read_csv.md) | Read a comma-separated values (csv) file into DataFrame. | +| [`readCSV`](danfo.read_csv.md) | Read a comma-separated values (csv) file into DataFrame. | | [`read_excel`](danfo.read_excel.md) | Read an Excel values (xlsx) file into DataFrame. | -| [`read_json`](danfo.read_json.md) | Read a JSON values (json) file into DataFrame. | -| [to_csv](danfo.to_csv.md) | Writes a DataFrame/Series to CSV file | +| [`readJSON`](danfo.read_json.md) | Read a JSON values (json) file into DataFrame. | +| [toCSV](danfo.to_csv.md) | Writes a DataFrame/Series to CSV file | | [to_excel](danfo.to_excel.md) | Writes a DataFrame/Series to Excel file | -| [to_json](danfo.to_json.md) | Writes a DataFrame/Series to JSON file | +| [toJSON](danfo.to_json.md) | Writes a DataFrame/Series to JSON file | -Writing to `CSV` and `JSON` can also be done directly from DataFrame or Series objects (e.g. [`DataFrame.to_csv()`](../dataframe/dataframe.to_csv.md)) +Writing to `CSV` and `JSON` can also be done directly from DataFrame or Series objects (e.g. [`DataFrame.toCSV()`](../dataframe/dataframe.to_csv.md)) diff --git a/api-reference/input-output/danfo.read_csv.md b/api-reference/input-output/danfo.read_csv.md index 870f105..c389d5d 100644 --- a/api-reference/input-output/danfo.read_csv.md +++ b/api-reference/input-output/danfo.read_csv.md @@ -66,7 +66,7 @@ dfd.readCSV("https://raw.githubusercontent.com/plotly/datasets/master/finance-ch - + Document @@ -106,7 +106,7 @@ By specifying a valid [file object](https://developer.mozilla.org/en-US/docs/Web - + Document diff --git a/api-reference/input-output/danfo.read_excel.md b/api-reference/input-output/danfo.read_excel.md index 5359117..75d2fe2 100644 --- a/api-reference/input-output/danfo.read_excel.md +++ b/api-reference/input-output/danfo.read_excel.md @@ -6,10 +6,10 @@ description: Reads a JSON file from local or remote location into a DataFrame. > danfo.**readExcel**(source, options) -| Parameters | Type | Description | -| ---------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| source | string | **source** : string, URL or local file path to Excel file. | -| options | Object |

{

sheet : string, (Optional) Name of the sheet which u want to parse. Default will be the first sheet.
method: The HTTP method to use.

headers: Additional headers to send with the request if reading JSON from remote url. Supports all the node-fetch options in Nodejs, and all fetch options in browsers.

}

| +| Parameters | Type | Description | +| ---------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| source | string | **source** : string, URL or local file path to Excel file. | +| options | Object |

{

sheet : string, (Optional) Name of the sheet which u want to parse. Default will be the first sheet.
method: The HTTP method to use.

headers: Additional headers to send with the request if reading JSON from remote url. Supports all the node-fetch options in Nodejs, and all fetch options in browsers.

frameConfig: Optional arguments passed when creating the DataFrame. e.g column names, index. etc.

parsingOptions: supports all xlsx options. See https://docs.sheetjs.com/docs/api/parse-options

}

| ### Example @@ -40,7 +40,7 @@ load_process_data() - + Document @@ -62,8 +62,6 @@ load_process_data() {% endtab %} {% endtabs %} - - ### **Reading an input file object in the browser** By specifying a valid [file object](https://developer.mozilla.org/en-US/docs/Web/API/File), you can load Excel files in the browser in DataFrames/Series @@ -77,14 +75,15 @@ By specifying a valid [file object](https://developer.mozilla.org/en-US/docs/Web - + Document + Document @@ -99,7 +99,7 @@ By specifying a valid [file object](https://developer.mozilla.org/en-US/docs/Web - + Document diff --git a/api-reference/input-output/danfo.to_csv.md b/api-reference/input-output/danfo.to_csv.md index e502326..9798a11 100644 --- a/api-reference/input-output/danfo.to_csv.md +++ b/api-reference/input-output/danfo.to_csv.md @@ -48,7 +48,7 @@ Abs,Count,country code - + Document diff --git a/api-reference/input-output/danfo.to_excel.md b/api-reference/input-output/danfo.to_excel.md index 511381a..146f70c 100644 --- a/api-reference/input-output/danfo.to_excel.md +++ b/api-reference/input-output/danfo.to_excel.md @@ -6,18 +6,18 @@ description: >- # danfo.toExcel -> danfo.**toExcel**(data, options) +> danfo.**toExcel**(data, options) -| **Parameters** | Type | Description | Default | -| -------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -| _**data**_ | Series or DataFrame | The Series or DataFrame to write to CSV | | -| **options** | object, optional |

Configuration object:

{

filePath: Local file path to write the CSV file to. If not specified, the CSV will be returned as a string. Only needed in Nodejs version
fileName: The name of the file to download as. Only needed in the browser environment.
sheetName: Name to call the excel sheet.

}

|

{
filePath: "./output.xlsx",
sheetName: "Sheet1"

}

| +| **Parameters** | Type | Description | Default | +| -------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | +| _**data**_ | Series or DataFrame | The Series or DataFrame to write to CSV | | +| **options** | object, optional |

Configuration object:

{

filePath: Local file path to write the CSV file to. If not specified, the CSV will be returned as a string. Only needed in Nodejs version
fileName: The name of the file to download as. Only needed in the browser environment.
sheetName: Name to call the excel sheet.

writingOptions: Supports all xlsx write options. See https://docs.sheetjs.com/docs/api/write-options

}

|

{
filePath: "./output.xlsx",
sheetName: "Sheet1"

}

| The **toExcel** function can be used to write out a DataFrame or Series to Excel (**.xlsx**) file. The output format will depend on the environment. In the following examples, we show you how to write/download an Excel file from Node and Browser environments. ### Convert DataFrame to Excel and write to file path -Writing an Excel file to a local file path is only supported in the Nodejs environment +You can write a DataFrame or Series in Excel format using the toExcel function and specifying the file path. {% tabs %} {% tab title="Node.js" %} @@ -39,7 +39,7 @@ dfd.toExcel(df, { filePath: "testOut.xlsx"}); ### Convert DataFrame to Excel and download the file in Client-side lib -You can automatically convert and download an Excel file in a browser environment, by specifying a filename and setting download to `true` +You can automatically convert and download an Excel file in a browser environment, by specifying a filename. This will open a download window. ```javascript let data = { @@ -50,5 +50,5 @@ let data = { let df = new DataFrame(data); -dfd.toExcel(df, { fileName: "testOut.xlsx", download: true}); +dfd.toExcel(df, { fileName: "testOut.xlsx"}); ``` diff --git a/api-reference/input-output/danfo.to_json.md b/api-reference/input-output/danfo.to_json.md index bdcafc9..18816d7 100644 --- a/api-reference/input-output/danfo.to_json.md +++ b/api-reference/input-output/danfo.to_json.md @@ -58,7 +58,7 @@ console.log(jsonObj); - + Document diff --git a/api-reference/plotting/bar-charts.md b/api-reference/plotting/bar-charts.md index e62390c..5dab386 100644 --- a/api-reference/plotting/bar-charts.md +++ b/api-reference/plotting/bar-charts.md @@ -17,7 +17,7 @@ A bar plot presents categorical data with rectangular bars with lengths proporti - + Document @@ -35,7 +35,7 @@ A bar plot presents categorical data with rectangular bars with lengths proporti ``` -![](<../../.gitbook/assets/newplot (6).png>) +![](../../.gitbook/assets/newplot-6-.png) ### Bar plot on DataFrame @@ -46,7 +46,7 @@ A bar plot presents categorical data with rectangular bars with lengths proporti - + @@ -64,7 +64,7 @@ A bar plot presents categorical data with rectangular bars with lengths proporti ``` -![](<../../.gitbook/assets/newplot (7).png>) +![](../../.gitbook/assets/newplot-7-.png) {% hint style="info" %} To customize plots, see the [Customizing your plot page](configuring-your-plots.md) diff --git a/api-reference/plotting/box-plots.md b/api-reference/plotting/box-plots.md index da440d5..326fed7 100644 --- a/api-reference/plotting/box-plots.md +++ b/api-reference/plotting/box-plots.md @@ -35,7 +35,6 @@ function App() { } export default App; - ``` {% endcode %} {% endtab %} @@ -61,7 +60,6 @@ export default App; - ``` {% endtab %} {% endtabs %} @@ -102,7 +100,6 @@ function App() { } export default App; - ``` {% endcode %} {% endtab %} @@ -137,7 +134,6 @@ export default App; - ``` {% endtab %} {% endtabs %} @@ -183,7 +179,6 @@ function App() { } export default App; - ``` {% endcode %} {% endtab %} @@ -217,7 +212,6 @@ export default App; - ``` {% endtab %} {% endtabs %} diff --git a/api-reference/plotting/configuring-your-plots.md b/api-reference/plotting/configuring-your-plots.md index dccfa01..2ad915e 100644 --- a/api-reference/plotting/configuring-your-plots.md +++ b/api-reference/plotting/configuring-your-plots.md @@ -15,7 +15,7 @@ The config parameter extends the [Plotly.js config](https://plotly.com/javascrip | **columns** | Array of column names to plot. | All columns in the DataFrame when applicable | | **values** | Used to configure a `pie` chart. A column name containing values for the pie. Maps 1-1 with labels. | | | **labels** | Used to configure a `pie` chart. A column name containing labels for the pie. Maps 1-1 with values. | | -| **rowPositions** | Used to configure a `pie` chart. Pie chart domain row. See [https://plotly.com/javascript/reference/pie/#pie-domain-row](https://plotly.com/javascript/reference/pie/#pie-domain-row) | Range of `0 - DataFrame column length` | +| **rowPositions** | Used to configure a `pie` chart. Pie chart domain row. See [https://plotly.com/javascript/reference/pie/#pie-domain-row](https://plotly.com/javascript/reference/pie/#pie-domain-row) | Range of `0 - DataFrame column length` | | **columnPositions** | Used to configure a `pie` chart. Pie chart domain column. See [https://plotly.com/javascript/reference/pie/#pie-domain-column](https://plotly.com/javascript/reference/pie/#pie-domain-column) | Range of `0 - DataFrame column length` | | **grid** |

Used to configure a pie chart. Accepts the following parameter:

row: Integer size
column: Integer size

| | | **tableHeaderStyle** | Table properties used for configuring table header. See [full list](https://plotly.com/javascript/reference/table/#table-header) of supported arguments. | | @@ -80,7 +80,6 @@ function App() { } export default App; - ``` {% endtab %} @@ -134,7 +133,6 @@ export default App; - ``` {% endtab %} {% endtabs %} diff --git a/api-reference/plotting/histograms.md b/api-reference/plotting/histograms.md index 8a9a2e1..c2691cb 100644 --- a/api-reference/plotting/histograms.md +++ b/api-reference/plotting/histograms.md @@ -42,7 +42,6 @@ function App() { } export default App; - ``` {% endtab %} @@ -80,7 +79,7 @@ export default App; {% endtab %} {% endtabs %} -![](<../../.gitbook/assets/newplot (10).png>) +![](../../.gitbook/assets/newplot-10-.png) ### Customized Histogram plots on DataFrame @@ -135,7 +134,7 @@ a - + Document @@ -169,7 +168,7 @@ a {% endtab %} {% endtabs %} -![](<../../.gitbook/assets/newplot (20).png>) +![](../../.gitbook/assets/newplot-20-.png) {% hint style="info" %} For more configuration options for Histograms, see the [Plotly](https://plotly.com/javascript/histograms/) doc. diff --git a/api-reference/plotting/line-charts.md b/api-reference/plotting/line-charts.md index aa1cd50..89a2aea 100644 --- a/api-reference/plotting/line-charts.md +++ b/api-reference/plotting/line-charts.md @@ -17,7 +17,7 @@ description: >- - + Document @@ -35,7 +35,7 @@ description: >- ``` -![](<../../.gitbook/assets/newplot (4).png>) +![](../../.gitbook/assets/newplot-4-.png) ### Line plots on DataFrame @@ -48,7 +48,7 @@ The example below shows the plot of column values against a common x-axis (index - + Document @@ -67,7 +67,7 @@ The example below shows the plot of column values against a common x-axis (index ``` -![](<../../.gitbook/assets/newplot (2).png>) +![](<../../.gitbook/assets/newplot (2) (2).png>) The example below shows how to plot two columns in a DataFrame against each other. @@ -79,7 +79,7 @@ The example below shows how to plot two columns in a DataFrame against each othe - + Document @@ -105,7 +105,7 @@ The example below shows how to plot two columns in a DataFrame against each othe ``` -![](<../../.gitbook/assets/newplot (3).png>) +![](../../.gitbook/assets/newplot-3-.png) {% hint style="info" %} To customize your plots, see the [Customize your plot page](configuring-your-plots.md) diff --git a/api-reference/plotting/pie-charts.md b/api-reference/plotting/pie-charts.md index 8776b7f..096de25 100644 --- a/api-reference/plotting/pie-charts.md +++ b/api-reference/plotting/pie-charts.md @@ -39,7 +39,6 @@ function App() { } export default App; - ``` {% endtab %} @@ -75,7 +74,7 @@ e {% endtab %} {% endtabs %} -![](<../../.gitbook/assets/newplot (12).png>) +![](../../.gitbook/assets/newplot-12-.png) ### Multiple Pie Chart from Columns in a DataFrame @@ -87,7 +86,7 @@ e - + Document @@ -117,13 +116,13 @@ e ``` -![](<../../.gitbook/assets/newplot (21).png>) +![](../../.gitbook/assets/newplot-21-.png) ### Configure Position of Pie Charts If you have more than one pie chart to display, you can set the grid parameter, and also the position of each pie. - For example, in the snippet below, we set the `grid` to 2 by 2 and also pass a set of row and column index positions. Each row/column position index corresponds to each pie. +For example, in the snippet below, we set the `grid` to 2 by 2 and also pass a set of row and column index positions. Each row/column position index corresponds to each pie. ```markup @@ -132,7 +131,7 @@ If you have more than one pie chart to display, you can set the grid parameter, - + Document @@ -163,7 +162,7 @@ If you have more than one pie chart to display, you can set the grid parameter, ``` -![](<../../.gitbook/assets/newplot (22).png>) +![](../../.gitbook/assets/newplot-22-.png) {% hint style="info" %} For more configuration options for Pie Charts, see the [Plotly](https://plotly.com/javascript/pie-charts/) style doc. diff --git a/api-reference/plotting/scatter-plots.md b/api-reference/plotting/scatter-plots.md index 92f239b..55e6a39 100644 --- a/api-reference/plotting/scatter-plots.md +++ b/api-reference/plotting/scatter-plots.md @@ -19,7 +19,7 @@ In the example below, we use the titanic dataset, to show a close to real-world - + Document @@ -45,7 +45,7 @@ In the example below, we use the titanic dataset, to show a close to real-world ``` -![](<../../.gitbook/assets/newplot-8- (1) (1).png>) +![](<../../.gitbook/assets/newplot-8- (1).png>) ### More Examples @@ -56,7 +56,7 @@ In the example below, we use the titanic dataset, to show a close to real-world - + Document @@ -85,7 +85,7 @@ In the example below, we use the titanic dataset, to show a close to real-world ``` -![](<../../.gitbook/assets/newplot (19).png>) +![](../../.gitbook/assets/newplot-19-.png) {% hint style="info" %} To customize your plots, see the [Customize your plot page](configuring-your-plots.md) diff --git a/api-reference/plotting/tables.md b/api-reference/plotting/tables.md index 7dfc1b5..2614b0b 100644 --- a/api-reference/plotting/tables.md +++ b/api-reference/plotting/tables.md @@ -38,7 +38,6 @@ function App() { } export default App; - ``` {% endcode %} {% endtab %} @@ -72,7 +71,6 @@ export default App; - ``` {% endtab %} {% endtabs %} @@ -134,7 +132,6 @@ function App() { } export default App; - ``` {% endcode %} {% endtab %} @@ -189,7 +186,6 @@ export default App; - ``` {% endtab %} {% endtabs %} diff --git a/api-reference/plotting/timeseries-plots.md b/api-reference/plotting/timeseries-plots.md index d34888e..cc49d74 100644 --- a/api-reference/plotting/timeseries-plots.md +++ b/api-reference/plotting/timeseries-plots.md @@ -105,12 +105,11 @@ export default App; - ``` {% endtab %} {% endtabs %} -![](<../../.gitbook/assets/newplot-29- (2) (1).png>) +![](<../../.gitbook/assets/newplot-29- (2) (1) (1) (3).png>) {% hint style="info" %} To set customize your charts, see the [Customizing your plot page](configuring-your-plots.md) diff --git a/api-reference/plotting/violin-plots.md b/api-reference/plotting/violin-plots.md index 3ea40a8..3609a01 100644 --- a/api-reference/plotting/violin-plots.md +++ b/api-reference/plotting/violin-plots.md @@ -44,7 +44,7 @@ export default App; - + Document @@ -64,7 +64,7 @@ export default App; {% endtab %} {% endtabs %} -![](<../../.gitbook/assets/newplot (25).png>) +![](../../.gitbook/assets/newplot-25-.png) ### Box plots on a DataFrame @@ -101,7 +101,6 @@ function App() { } export default App; - ``` {% endcode %} {% endtab %} @@ -114,7 +113,7 @@ export default App; - + Document @@ -123,7 +122,7 @@ export default App;
- ``` {% endtab %} {% endtabs %} -![](<../../.gitbook/assets/newplot (27).png>) +![](../../.gitbook/assets/newplot-27-.png) {% hint style="info" %} To customize your plots, see the [Configuring your plot page](configuring-your-plots.md) diff --git a/api-reference/series/creating-a-series.md b/api-reference/series/creating-a-series.md index b957807..ef11bc8 100644 --- a/api-reference/series/creating-a-series.md +++ b/api-reference/series/creating-a-series.md @@ -31,7 +31,7 @@ df.print() - Document + Document @@ -88,7 +88,7 @@ df.print() - Document + Document diff --git a/api-reference/series/series.at.md b/api-reference/series/series.at.md new file mode 100644 index 0000000..887050c --- /dev/null +++ b/api-reference/series/series.at.md @@ -0,0 +1,31 @@ +--- +description: Access a single value for a row/column label pair. +--- + +# Series.at + +> danfo.Series.at(label) + +| Parameters | Type | Description | Default | +| ---------- | ------ | ----------------- | ------- | +| label | String | label to index by | | + +**Return:** Scalar + + + +{% tabs %} +{% tab title="Node" %} +```javascript +const dfd = require("danfojs-node") + +let sf = new dfd.Series(["Apples", "Mango", "Banana", "Pear"], + { index: ["a", "b", "c", "d"] } +) + +sf.at("a") + +// "Apples" +``` +{% endtab %} +{% endtabs %} diff --git a/api-reference/series/series.iat.md b/api-reference/series/series.iat.md new file mode 100644 index 0000000..3f17e6b --- /dev/null +++ b/api-reference/series/series.iat.md @@ -0,0 +1,31 @@ +--- +description: Access a single value for a row/column pair by integer position. +--- + +# Series.iat + +> danfo.Series.iat(index) + +| Parameters | Type | Description | Default | +| ---------- | ------ | ------------ | ------- | +| index | Number | index value | | + +**Return:** Scalar + + + +{% tabs %} +{% tab title="Node" %} +```javascript +const dfd = require("danfojs-node") + +let sf = new dfd.Series(["Apples", "Mango", "Banana", "Pear"], + { index: ["a", "b", "c", "d"] } +) + +sf.iat(1) + +// "Mango" +``` +{% endtab %} +{% endtabs %} diff --git a/building-data-driven-applications-with-danfo.js-book.md b/building-data-driven-applications-with-danfo.js-book.md index cf3e174..0a40dc9 100644 --- a/building-data-driven-applications-with-danfo.js-book.md +++ b/building-data-driven-applications-with-danfo.js-book.md @@ -1,6 +1,6 @@ # Building Data Driven Applications with Danfo.js - Book -## Purchase on [Packt](https://www.packtpub.com/product/building-data-driven-applications-with-danfo-js/9781801070850) using _25Danfo_ code before 31st December 2020 and get 25% discount. +## Purchase on [Packt](https://www.packtpub.com/product/building-data-driven-applications-with-danfo-js/9781801070850) ## What this book is about @@ -38,4 +38,3 @@ This book is for data analysts, data scientists, and JavaScript developers who w 11. Building a Recommendation System with Danfo.js and TensorFlow.js 12. Building a Twitter Analysis Dashboard 13. Appendix: Essential JavaScript Concepts - diff --git a/examples/migrating-to-the-stable-version-of-danfo.js.md b/examples/migrating-to-the-stable-version-of-danfo.js.md index 07c8206..9f3869f 100644 --- a/examples/migrating-to-the-stable-version-of-danfo.js.md +++ b/examples/migrating-to-the-stable-version-of-danfo.js.md @@ -10,13 +10,11 @@ We recently released the first stable version of Danfo.js. See release note here The following list summarizes some of these updates: -* **Typescript support:** This new version has been completely re-written using Typescript. This means we now have well-defined types that increases the developer experience. -* **Standard naming convention:** Functions, methods, classes, and variable names have been standardized to follow JavaScript best practices. -* Standardize function argument: Functions and methods have been updated to accept arguments and parameters intuitively resulting in improved developer experience. -* **New features**: We added lots of new features which users have been requesting for. For example: +* **Typescript support:** This new version has been completely re-written using Typescript. This means we now have well-defined types that increase the developer experience. +* **Standard naming convention:** Functions, methods, classes, and variable names have been standardized to follow JavaScript best practices. +* Standardize function argument: Functions and methods have been updated to accept arguments and parameters intuitively resulting in improved developer experience. +* **New features**: We added a couple of new features which users have been requesting for. For example: * Stream and process large CSV data - * Read JSON objects with key support - * Date time is now a first-class data type. * General bug fixes and improvements * Better error messages @@ -30,11 +28,11 @@ Update your function and/or method names to use camelCase instead of snake\_case ```javascript read_csv ==> readCSV -to_json ==> toCSV +to_json ==> toJSON drop_duplicates ==> dropDuplicates ``` -**Note:** that your code editor auto-complete will general suggest the new function or method names, so it will be easier to update to the new names. If using Typescript, then it is even easier as the TS compiler will show you warnings. +**Note:** that your code editor will generally suggest the new function or method names, so it will be easier to update to the new names. If using Typescript, then it is even easier as the TS compiler will show you warnings. ### Functions and Methods argument structure @@ -42,7 +40,7 @@ Another major breaking change of v1, is that the structure of arguments/paramete In general, it is important to understand our thought process behind this, so, here goes: -Assuming we take the method called _**rename**_, which takes required object mapper, as well as, optional configuration argument. In pre-v1 version of Danfojs, the function signature is as follows: +Assuming we take the method called _**rename**_, which takes the required argument **mapper**, as well as, an optional configuration argument. In pre-v1 version of Danfojs, the function signature is as follows: ``` rename( { mapper, axis, inplace } ) => DataFrame @@ -54,10 +52,10 @@ The structure above combines both required and optional arguments as a single ob rename(mapper, options: {axis, inplace}) //where mapper is required, and options argument is optional. ``` -Re-designing functions and methods to follow this intuitive format is the bulk of the breaking change in this new version, as such, when migrating, you have to make these updates. +Re-designing functions and methods to follow this intuitive format is the bulk of the breaking change in this new version, as such, when migrating, you have to make these updates. {% hint style="info" %} -If using Typescript, then the TS compiler will help in migration, else, you have to manually identify and update your function/method signature. +If using Typescript, then the TS compiler will help in migration, else, you have to manually identify and update your function/method signature. {% endhint %} ### Axis Order @@ -65,28 +63,7 @@ If using Typescript, then the TS compiler will help in migration, else, you have In this new version, we have flipped the result of the axis ordering for all operations. This ordering is now consistent with Pandas and Tensorflow.js. That is, the axis row (0), represents the operations carried out horizontally on a DataFrame, and the axis columns (1) represent operations carried out vertically down the DataFrame. {% hint style="info" %} -In short, when migrating to the new version, you should flip the axis number so as to get the same result. That is, change all `axis: 0` to `axis: 1`, to get the same result. +In short, when migrating to the new version, you should flip the axis number so as to get the same result. That is, change all `axis: 0` to `axis: 1`, to get the same result. {% endhint %} -All examples in this doc have been updated to reflect this update. - - - - - - - - - - - - - - - - - - - - - +All examples in this doc have been updated to reflect this update. diff --git a/examples/titanic-survival-prediction-using-danfo.js-and-tensorflow.js.md b/examples/titanic-survival-prediction-using-danfo.js-and-tensorflow.js.md index 9ee7073..219b123 100644 --- a/examples/titanic-survival-prediction-using-danfo.js-and-tensorflow.js.md +++ b/examples/titanic-survival-prediction-using-danfo.js-and-tensorflow.js.md @@ -53,7 +53,7 @@ Below your import add the following lines of code: ```javascript async function load_process_data() { - let df = await dfd.redCSV("https://web.stanford.edu/class/archive/cs/cs109/cs109.1166/stuff/titanic.csv") + let df = await dfd.readCSV("https://web.stanford.edu/class/archive/cs/cs109/cs109.1166/stuff/titanic.csv") df.head().print() @@ -77,7 +77,7 @@ async function load_process_data() { ╚═══╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ ``` -You wrote an async function because loading a dataset over the internet takes a few seconds depending on your network. Inside the async function, you pass in the url of the titanic dataset to the read\_csv function. +You wrote an async function because loading a dataset over the internet takes a few seconds depending on your network. Inside the async function, you pass in the url of the titanic dataset to the readCSV function. Next you'll perform some basic data preprocessing. The [ctypes](../api-reference/dataframe/dataframe.dtypes.md) attribute returns the column data types: @@ -107,7 +107,7 @@ df.ctypes.print() ╚═════════════════════════╧══════════════════════╝ ``` -From the data types table above, you'll notice that there are two strong columns. The first is the Name column which contains Names of each passenger. From the head of the dataset you printed above, you'll confirm that each name has a title. So you can extract these titles from the names and this can serve as a new feature. +From the data types table above, you'll notice that there are two string columns. The first is the Name column which contains Names of each passenger. From the head of the dataset you printed above, you'll confirm that each name has a title. So you can extract these titles from the names and this can serve as a new feature. ```javascript //A feature engineering: Extract all titles from names columns @@ -145,7 +145,7 @@ let encoder = new dfd.LabelEncoder() let cols = ["Sex", "Name"] cols.forEach(col => { encoder.fit(df[col]) - enc_val = encoder.transform(df[col]) + const enc_val = encoder.transform(df[col]) df.addColumn( col, enc_val, { inplace: true }) }) @@ -225,7 +225,7 @@ async function load_process_data() { let cols = ["Sex", "Name"] cols.forEach(col => { encoder.fit(df[col]) - enc_val = encoder.transform(df[col]) + const enc_val = encoder.transform(df[col]) df.addColumn( col, enc_val, { inplace: true }) }) diff --git a/getting-started.md b/getting-started.md index de8a123..b0510f1 100644 --- a/getting-started.md +++ b/getting-started.md @@ -7,9 +7,9 @@ description: >- # Getting Started {% hint style="info" %} -A stable version of Danfojs (v1), has been released, and it comes with full Typescript support, new features, and many bug fixes. See release note [here](release-notes.md#latest-release-node-v1.0.0-browser-v1.0.0). +A stable version of Danfojs (v1), has been released, and it comes with full Typescript support, new features, and many bug fixes. See release note [here](release-notes.md#latest-release-node-v1.0.0-browser-v1.0.0). -There are a couple of breaking changes, so we have prepared a short migration [guide](examples/migrating-to-the-stable-version-of-danfo.js.md) for pre-v1.0.0 users. +There are a couple of breaking changes, so we have prepared a short migration [guide](examples/migrating-to-the-stable-version-of-danfo.js.md) for pre-v1 users. {% endhint %} ## Installation @@ -36,14 +36,14 @@ or yarn add danfojs ``` -For use directly in HTML files, you can add the latest script tag from [JsDelivr](https://www.jsdelivr.com/package/npm/danfojs?version=0.3.1\&path=lib): +For use directly in HTML files, you can add the latest script tag from [JsDelivr](https://www.jsdelivr.com/package/npm/danfojs): ```markup - + ``` {% hint style="info" %} -To play with Danfo.js in a Notebook-like environment, see [Dnotebooks](https://dnotebook.jsdata.org/getting-started) [here](https://playnotebook.jsdata.org/demo) or the [VS-Code Nodejs notebook extension](https://marketplace.visualstudio.com/items?itemName=donjayamanne.typescript-notebook). +To play with Danfo.js in a Notebook-like environment, see [Dnotebooks](https://dnotebook.jsdata.org/getting-started) [here](https://playnotebook.jsdata.org/demo) or the [VS-Code Nodejs notebook extension](https://marketplace.visualstudio.com/items?itemName=donjayamanne.typescript-notebook). {% endhint %} ## 10 minutes to danfo.js @@ -70,7 +70,7 @@ import * as dfd from "danfojs-node" - + @@ -120,7 +120,7 @@ s.print() - Document + Document @@ -181,7 +181,7 @@ s.print() - + Document @@ -242,7 +242,8 @@ df.print() - Document + +Document @@ -290,7 +291,7 @@ df.ctypes.print() - Document + Document @@ -368,7 +369,7 @@ df.print() - Document + Document @@ -459,7 +460,7 @@ df.print() - Document + Document @@ -567,7 +568,7 @@ let dates = new dfd.dateRange({ - Document + Document @@ -652,7 +653,7 @@ df.tensor.print() - Document + Document @@ -732,7 +733,7 @@ df.describe().print() - Document + Document @@ -805,7 +806,7 @@ df.print() - Document + Document @@ -875,7 +876,7 @@ df['A'].print() - Document + Document @@ -1292,7 +1293,7 @@ df.print() - Document + Document @@ -1340,13 +1341,13 @@ df.print() ╔════════════╤═══════════════════╤═══════════════════╤═══════════════════╤═══════════════════╗ ║ │ A │ B │ C │ D ║ ╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 0 │ 1 │ 2 │ 3 │ 25 ║ +║ 0 │ 30 │ 34 │ 20 │ 1 ║ ╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 1 │ 4 │ 5 │ 6 │ 35 ║ +║ 1 │ 1 │ 4 │ 20 │ 2 ║ ╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 2 │ 20 │ 30 │ 40 │ 45 ║ +║ 2 │ 2 │ 5 │ 30 │ 3 ║ ╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ -║ 3 │ 39 │ 89 │ 78 │ 55 ║ +║ 3 │ 3 │ 6 │ 40 │ 4 ║ ╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ ``` @@ -1381,7 +1382,7 @@ df_drop.print() - Document + Document @@ -1599,7 +1600,7 @@ df.mean().print() //defaults to column (1) axis - Document + Document @@ -1884,7 +1885,6 @@ com_df.print() ╟────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────┼───────────────────╢ ║ 3 │ K2 │ K2 │ A3 │ B3 │ K2 │ K0 │ C3 │ D3 ║ ╚════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╧═══════════════════╝ - ``` Concatenate along row axis (0). @@ -2030,9 +2030,9 @@ let df = new dfd.DataFrame(data) let grp = df.groupby(["A"]) -grp.get_groups(["foo"]).print() +grp.getGroup(["foo"]).print() -grp.get_groups(["bar"]).print() +grp.getGroup(["bar"]).print() ``` ``` @@ -2202,20 +2202,10 @@ sf.dt.dayOfWeekName().print() See the [Plotting](api-reference/plotting/) docs. -We currently support [Plotly.js](https://plotly.com/javascript/) for plotting. In the future, we plan other JS plotting libraries like Vega, D3. +We currently support [Plotly.js](https://plotly.com/javascript/) for plotting. In the future, we plan other JS plotting libraries like Vega, D3. Using the `plot` API, you can make interactive plots from DataFrame and Series. Plotting only works in the browser/client-side version of Danfo.js, and requires an HTML div to display plots. -{% tabs %} -{% tab title="Browser" %} - -{% endtab %} - -{% tab title="Second Tab" %} - -{% endtab %} -{% endtabs %} - ```markup @@ -2223,7 +2213,7 @@ Using the `plot` API, you can make interactive plots from DataFrame and Series. - + Document @@ -2263,7 +2253,7 @@ Using the `plot` API, you can make interactive plots from DataFrame and Series. ``` -![](<.gitbook/assets/newplot-29- (2).png>) +![](<.gitbook/assets/newplot-29- (2) (1).png>) On a DataFrame, the [`plot()`](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.plot.html#pandas.DataFrame.plot)method exposes various [plot types](api-reference/plotting/). And by default, all columns are plotted unless specified otherwise. @@ -2275,7 +2265,7 @@ On a DataFrame, the [`plot()`](https://pandas.pydata.org/pandas-docs/stable/refe - + Document @@ -2302,7 +2292,7 @@ On a DataFrame, the [`plot()`](https://pandas.pydata.org/pandas-docs/stable/refe [Writing to a CSV file.](api-reference/dataframe/dataframe.to\_csv.md) -Convert any DataFrame to csv format. +Convert any DataFrame to csv format. In NodeJs, if a file path is specified, then the CSV is saved to the path, else it is returned as a string. @@ -2319,7 +2309,7 @@ let data = { let df = new dfd.DataFrame(data) -const csv = df.toCSV() +const csv = dfd.toCSV(df) console.log(csv); //output Abs,Count,country code @@ -2328,10 +2318,10 @@ Abs,Count,country code 47.3,5,GH -df.toCSV({filePath: "testOut.csv" }) //writes to file system in Nodejs +dfd.toCSV(df, {filePath: "testOut.csv" }) //writes to file system in Nodejs -df.toCSV({fileName: "testOut", download: true }) //downloads the file in browser version +dfd.toCSV(df, {fileName: "testOut", download: true }) //downloads the file in browser version ``` ``` @@ -2370,7 +2360,7 @@ dfd.readCSV("/home/Desktop/titanic.csv") - + Document @@ -2378,7 +2368,7 @@ dfd.readCSV("/home/Desktop/titanic.csv") - + Document @@ -150,7 +224,7 @@ A simple example: }) - +