# 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`](https://danfo.jsdata.org/api-reference/series/series.index) | The index (axis labels) of the Series. |
| ---------------------------------------------------------------------------- | -------------------------------------- |

| [`Series.tensor`](https://danfo.jsdata.org/api-reference/series/series.tensor)                                             | The Tensorflow tensor of the data backing this Series or Index.  |
| -------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| [`Series.values`](https://danfo.jsdata.org/api-reference/series/series.values)                                             | Return Series as ndarray or ndarray-like depending on the dtype. |
| [`Series.dtype`](https://danfo.jsdata.org/api-reference/series/series.dtype)                                               | Return the dtype object of the underlying data.                  |
| [`Series.shape`](https://danfo.jsdata.org/api-reference/series/series.shape)                                               | Return a tuple of the shape of the underlying data.              |
| [`Series.ndim`](https://danfo.jsdata.org/api-reference/series/series.ndim)                                                 | Number of dimensions of the underlying data, by definition 1.    |
| [`Series.size`](https://github.com/javascriptdata/danfojs-doc/blob/master/api-reference/series/broken-reference/README.md) | Return the number of elements in the underlying data.            |

### Conversion

| [`Series.asType`](https://danfo.jsdata.org/api-reference/dataframe/dataframe.astype) | Cast a Series object to a specified dtype      |
| ------------------------------------------------------------------------------------ | ---------------------------------------------- |
| [`Series.copy`](https://danfo.jsdata.org/api-reference/series/series.copy)           | Make a copy of this object’s indices and data. |

### Indexing, iteration

|                                                                            |                                                                    |
| -------------------------------------------------------------------------- | ------------------------------------------------------------------ |
| ``[`Series.loc`](series.loc.md)``                                          | Access a group of rows and columns by label(s) or a boolean array. |
| [`Series.iloc`](https://danfo.jsdata.org/api-reference/series/series.iloc) | Purely integer-location based indexing for selection by position.  |

### Binary operator functions

| [`Series.add`](https://danfo.jsdata.org/api-reference/series/series.add)     | Return Addition of series and other, element-wise (binary operator add).                |
| ---------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| [`Series.sub`](https://danfo.jsdata.org/api-reference/series/series.sub)     | Return Subtraction of series and other, element-wise (binary operator sub).             |
| [`Series.mul`](https://danfo.jsdata.org/api-reference/series/series.mul)     | Return Multiplication of series and other, element-wise (binary operator mul).          |
| [`Series.div`](https://danfo.jsdata.org/api-reference/series/series.div)     | Return Floating division of series and other, element-wise (binary operator truediv).   |
| [`Series.mod`](https://danfo.jsdata.org/api-reference/series/series.mod)     | Return Modulo of series and other, element-wise (binary operator mod).                  |
| [`Series.pow`](https://danfo.jsdata.org/api-reference/series/series.pow)     | Return Exponential power of series and other, element-wise (binary operator pow).       |
| [`Series.round`](https://danfo.jsdata.org/api-reference/series/series.round) | Round each value in a Series to the given number of decimals.                           |
| [`Series.lt`](https://danfo.jsdata.org/api-reference/series/series.lt)       | Return Less than of series and other, element-wise (binary operator lt).                |
| [`Series.gt`](https://danfo.jsdata.org/api-reference/series/series.gt)       | Return Greater than of series and other, element-wise (binary operator gt).             |
| [`Series.le`](https://danfo.jsdata.org/api-reference/series/series.le)       | Return Less than or equal to of series and other, element-wise (binary operator le).    |
| [`Series.ge`](https://danfo.jsdata.org/api-reference/series/series.ge)       | Return Greater than or equal to of series and other, element-wise (binary operator ge). |
| [`Series.ne`](https://danfo.jsdata.org/api-reference/series/series.ne)       | Return Not equal to of series and other, element-wise (binary operator ne).             |
| [`Series.eq`](https://danfo.jsdata.org/api-reference/series/series.eq)       | Return Equal to of series and other, element-wise (binary operator eq).                 |

### Function application

| [`Series.apply`](https://danfo.jsdata.org/api-reference/series/series.apply) | Invoke function on values of Series.                    |
| ---------------------------------------------------------------------------- | ------------------------------------------------------- |
| [`Series.map`](https://danfo.jsdata.org/api-reference/series/series.map)     | Map values of Series according to input correspondence. |

### Computations / descriptive stats

| [`Series.abs`](https://danfo.jsdata.org/api-reference/series/series.abs)                                                   | Return a Series with absolute numeric value of each element.     |
| -------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| [`Series.corr`](https://github.com/javascriptdata/danfojs-doc/blob/master/api-reference/series/broken-reference/README.md) | Compute correlation with other Series, excluding missing values. |
| [`Series.count`](https://danfo.jsdata.org/api-reference/series/series.count)                                               | Return number of non-NaN observations in the Series.             |
| [`Series.cumMax`](https://danfo.jsdata.org/api-reference/dataframe/danfo.dataframe.cummax)                                 | Return cumulative maximum over a DataFrame or Series axis.       |
| [`Series.cumMin`](https://danfo.jsdata.org/api-reference/dataframe/danfo.dataframe.cummin)                                 | Return cumulative minimum over a DataFrame or Series axis.       |
| [`Series.cumProd`](https://danfo.jsdata.org/api-reference/dataframe/danfo.dataframe.cumprod)                               | Return cumulative product over a DataFrame or Series axis.       |
| [`Series.cumSum`](https://danfo.jsdata.org/api-reference/dataframe/danfo.dataframe.cumsum)                                 | Return cumulative sum over a DataFrame or Series axis.           |
| [`Series.describe`](https://danfo.jsdata.org/api-reference/series/series.describe)                                         | Generate descriptive statistics.                                 |
| [`Series.max`](https://danfo.jsdata.org/api-reference/series/series.max)                                                   | Return the maximum of the values for the requested axis.         |
| [`Series.mean`](https://danfo.jsdata.org/api-reference/series/series.mean)                                                 | Return the mean of the values for the requested axis.            |
| [`Series.median`](https://danfo.jsdata.org/api-reference/series/series.median)                                             | Return the median of the values for the requested axis.          |
| [`Series.min`](https://danfo.jsdata.org/api-reference/series/series.min)                                                   | Return the minimum of the values for the requested axis.         |
| [`Series.mode`](https://danfo.jsdata.org/api-reference/series/series.mode)                                                 | Return the mode(s) of the dataset.                               |
| [`Series.std`](https://danfo.jsdata.org/api-reference/series/series.std)                                                   | Return sample standard deviation over requested axis.            |
| [`Series.sum`](https://danfo.jsdata.org/api-reference/series/series.sum)                                                   | Return the sum of the values for the requested axis.             |
| [`Series.var`](https://danfo.jsdata.org/api-reference/series/series.var)                                                   | Return unbiased variance over requested axis.                    |
| [`Series.unique`](https://danfo.jsdata.org/api-reference/series/series.unique)                                             | Return unique values of Series object.                           |
| [`Series.nUnique`](https://danfo.jsdata.org/api-reference/series/series.nunique)                                           | Return number of unique elements in the object.                  |
| [`Series.valueCounts`](https://danfo.jsdata.org/api-reference/series/series.value_counts)                                  | Return a Series containing counts of unique values.              |

### Reindexing / selection / label manipulation

|                                                                                                 |                                                          |
| ----------------------------------------------------------------------------------------------- | -------------------------------------------------------- |
| [`Series.dropDuplicates`](https://danfo.jsdata.org/api-reference/series/series.drop_duplicates) | Return Series with duplicate values removed.             |
| [`Series.head`](https://danfo.jsdata.org/api-reference/series/series.head)                      | Return the first n rows.                                 |
| [`Series.resetIndex`](https://danfo.jsdata.org/api-reference/series/series.reset_index)         | Generate a new DataFrame or Series with the index reset. |
| [`Series.sample`](https://danfo.jsdata.org/api-reference/series/series.sample)                  | Return a random sample of items from an axis of object.  |
| [`Series.tail`](https://danfo.jsdata.org/api-reference/series/series.tail)                      | Return the last n rows.                                  |

### Missing data handling

|                                                                                  |                                                  |
| -------------------------------------------------------------------------------- | ------------------------------------------------ |
| [`Series.droNa`](https://danfo.jsdata.org/api-reference/series/series.dropna)    | Return a new Series with missing values removed. |
| [`Series.fillNa`](https://danfo.jsdata.org/api-reference/series/series.fillna)   | Fill NaN values using the specified method.      |
| [`Series.isNa`](https://danfo.jsdata.org/api-reference/series/series.isna)       | Detect missing values.                           |
| [`Series.replace`](https://danfo.jsdata.org/api-reference/series/series.replace) | Replace values given in to\_replace with value.  |

### Logical Comparison

|                                                                          |                                                                                                      |
| ------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------- |
| [`Series.or`](https://danfo.jsdata.org/api-reference/series/series.or)   | Returns the logical OR between Series and other. Supports element-wise operations and broadcasting.  |
| [`Series.and`](https://danfo.jsdata.org/api-reference/series/series.and) | Returns the logical AND between Series and other. Supports element-wise operations and broadcasting. |

### Reshaping, sorting

| [`Series.argSort`](https://danfo.jsdata.org/api-reference/series/series.argsort)        | Return the integer indices that would sort the Series values. |
| --------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
| [`Series.argMin`](https://danfo.jsdata.org/api-reference/series/series.argmin)          | Return int position of the smallest value in the Series.      |
| [`Series.argMax`](https://danfo.jsdata.org/api-reference/series/series.argmax)          | Return int position of the largest value in the Series.       |
| [`Series.sortValues`](https://danfo.jsdata.org/api-reference/series/series.sort_values) | 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](https://danfo.jsdata.org/api-reference/general-functions/danfo.dt) | dt       |
| [String](https://danfo.jsdata.org/api-reference/general-functions/danfo.str)  | 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.<property>`.

**Datetime methods**

|                                                                                               |                                                                         |
| --------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| [`Series.dt.year`](https://danfo.jsdata.org/api-reference/series/series.dt.year)              | The year of the datetime.                                               |
| [`Series.dt.month`](https://danfo.jsdata.org/api-reference/series/series.dt.month)            | Returns a numeric representation of the month. January=0 - December=11. |
| [Series.dt.monthName](https://danfo.jsdata.org/api-reference/series/series.dt.month_name)     |                                                                         |
| [`Series.dt.dayOfWeek`](https://danfo.jsdata.org/api-reference/series/series.dt.day)          | Returns the day of the week, in local time                              |
| [`Series.dt.hour`](https://danfo.jsdata.org/api-reference/series/series.dt.hour)              | The hours of the datetime.                                              |
| [`Series.dt.minute`](https://danfo.jsdata.org/api-reference/series/series.dt.minute)          | The minutes of the datetime.                                            |
| [`Series.dt.second`](https://danfo.jsdata.org/api-reference/series/series.dt.second)          | The seconds of the datetime.                                            |
| [`Series.dt.dayOfWeekName`](https://danfo.jsdata.org/api-reference/series/series.dt.weekdays) | Returns the name of the day, of the week, in local time                 |
| [`Series.dt.dayOfMonth`](https://danfo.jsdata.org/api-reference/series/series.dt.month_name)  | Returns the day of the month, in local time                             |

#### 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.<function/property>`.

| [`Series.str.capitalize`](https://danfo.jsdata.org/api-reference/series/series.str.capitalize)   | Capitalize the first character of each string                                                                                  |
| ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ |
| [`Series.str.toUpperCase`](https://danfo.jsdata.org/api-reference/series/series.str.touppercase) | Converts all characters to uppercase.                                                                                          |
| [`Series.str.toLowerCase`](https://danfo.jsdata.org/api-reference/series/series.str.tolowercase) | Converts all characters to lowercase.                                                                                          |
| [`Series.str.charAt`](https://danfo.jsdata.org/api-reference/series/series.str.charat)           | Returns the character at the specified index (position).                                                                       |
| [`Series.str.concat`](https://danfo.jsdata.org/api-reference/series/series.str.concat)           | Joins two or more strings/arrays.                                                                                              |
| [`Series.str.startsWith`](https://danfo.jsdata.org/api-reference/series/series.str.startswith)   | Checks whether a string begins with specified characters.                                                                      |
| [`Series.str.endsWith`](https://danfo.jsdata.org/api-reference/series/series.str.endswith)       | Checks whether a string ends with specified characters                                                                         |
| [`Series.str.includes`](https://danfo.jsdata.org/api-reference/series/series.str.includes)       | Checks whether a string contains the specified string/characters.                                                              |
| [`Series.str.indexOf`](https://danfo.jsdata.org/api-reference/series/series.str.indexof)         | Returns the position of the first found occurrence of a specified value in a string.                                           |
| [`Series.str.lastIndexOf`](https://danfo.jsdata.org/api-reference/series/series.str.lastindexof) | Returns the position of the last found occurrence of a specified value in a string.                                            |
| [`Series.str.repeat`](https://danfo.jsdata.org/api-reference/series/series.str.repeat)           | Returns a new string with a specified number of copies of an existing string.                                                  |
| [`Series.str.search`](https://danfo.jsdata.org/api-reference/series/series.str.search)           | Searches a string for a specified value, or regular expression, and returns the position of the match.                         |
| [`Series.str.slice`](https://danfo.jsdata.org/api-reference/series/series.str.slice)             | Extracts a part of a string and returns a new string.                                                                          |
| [`Series.str.split`](https://danfo.jsdata.org/api-reference/series/series.str.split)             | Splits a string into an array of substrings.                                                                                   |
| [`Series.str.substr`](https://danfo.jsdata.org/api-reference/series/series.str.substr)           | Extracts the characters from a string, beginning at a specified start position, and through the specified number of character. |
| [`Series.str.substring`](https://danfo.jsdata.org/api-reference/series/series.str.substring)     | Extracts the characters from a string, between two specified indices.                                                          |
| [`Series.str.len`](https://danfo.jsdata.org/api-reference/series/series.str.len)                 | Counts the number of characters in each string.                                                                                |
| [`Series.str.trim`](https://danfo.jsdata.org/api-reference/series/series.str.trim)               | Removes whitespace from both ends of a string.                                                                                 |
| [`Series.str.join`](https://danfo.jsdata.org/api-reference/series/series.str.join)               | Joins strings to specified value.                                                                                              |
| [`Series.str.replace`](https://danfo.jsdata.org/api-reference/series/series.str.replace)         | 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.<kind>`.

|                                                                                        |                                                               |
| -------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
| [`Series.plot.bar`](https://danfo.jsdata.org/api-reference/plotting/bar-charts)        | Vertical bar plot.                                            |
| [`Series.plot.box`](https://danfo.jsdata.org/api-reference/plotting/box-plots)         | Make a box plot of the DataFrame columns.                     |
| [`Series.plot.violin`](https://danfo.jsdata.org/api-reference/plotting/box-plots)      | Make a violin plot of the DataFrame columns.                  |
| [`Series.plot.hist`](https://danfo.jsdata.org/api-reference/plotting/histograms)       | Draw one histogram of the DataFrame’s columns.                |
| [`Series.plot.scatter`](https://danfo.jsdata.org/api-reference/plotting/scatter-plots) | Generate Kernel Density Estimate plot using Gaussian kernels. |
| [`Series.plot.line`](https://danfo.jsdata.org/api-reference/plotting/line-charts)      | Plot Series or DataFrame as lines.                            |
| [`Series.plot.pie`](https://danfo.jsdata.org/api-reference/plotting/pie-charts)        | Generate a pie plot.                                          |
| [`Timeseries Plots`](https://danfo.jsdata.org/api-reference/plotting/timeseries-plots) | Time series plots                                             |
| [`Table`](https://danfo.jsdata.org/api-reference/plotting/tables)                      | Display Series as Interactive table in a Div                  |

### Serialization / IO / conversion

|                                                                                       |                                              |
| ------------------------------------------------------------------------------------- | -------------------------------------------- |
| [`Series.toCSV`](https://danfo.jsdata.org/api-reference/dataframe/dataframe.to_csv)   | Convert DataFrame or Series to CSV.          |
| [`Series.toJSON`](https://danfo.jsdata.org/api-reference/dataframe/dataframe.to_json) | Convert DataFrame or Series to a JSON.       |
| Series.toExcel                                                                        | Convert DataFrame or Series to an excel file |
