> For the complete documentation index, see [llms.txt](https://danfo.jsdata.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://danfo.jsdata.org/api-reference/series.md).

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

| [`Series.tensor`](/api-reference/series/series.tensor.md)                                                                  | The Tensorflow tensor of the data backing this Series or Index.  |
| -------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
| [`Series.values`](/api-reference/series/series.values.md)                                                                  | Return Series as ndarray or ndarray-like depending on the dtype. |
| [`Series.dtype`](/api-reference/series/series.dtype.md)                                                                    | Return the dtype object of the underlying data.                  |
| [`Series.shape`](/api-reference/series/series.shape.md)                                                                    | Return a tuple of the shape of the underlying data.              |
| [`Series.ndim`](/api-reference/series/series.ndim.md)                                                                      | 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`](/api-reference/dataframe/dataframe.astype.md) | Cast a Series object to a specified dtype      |
| --------------------------------------------------------------- | ---------------------------------------------- |
| [`Series.copy`](/api-reference/series/series.copy.md)           | 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`](/api-reference/series/series.iloc.md) | Purely integer-location based indexing for selection by position.  |

### Binary operator functions

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

### Function application

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

### Computations / descriptive stats

| [`Series.abs`](/api-reference/series/series.abs.md)                                                                        | 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`](/api-reference/series/series.count.md)                                                                    | Return number of non-NaN observations in the Series.             |
| [`Series.cumMax`](/api-reference/dataframe/danfo.dataframe.cummax.md)                                                      | Return cumulative maximum over a DataFrame or Series axis.       |
| [`Series.cumMin`](/api-reference/dataframe/danfo.dataframe.cummin.md)                                                      | Return cumulative minimum over a DataFrame or Series axis.       |
| [`Series.cumProd`](/api-reference/dataframe/danfo.dataframe.cumprod.md)                                                    | Return cumulative product over a DataFrame or Series axis.       |
| [`Series.cumSum`](/api-reference/dataframe/danfo.dataframe.cumsum.md)                                                      | Return cumulative sum over a DataFrame or Series axis.           |
| [`Series.describe`](/api-reference/series/series.describe.md)                                                              | Generate descriptive statistics.                                 |
| [`Series.max`](/api-reference/series/series.max.md)                                                                        | Return the maximum of the values for the requested axis.         |
| [`Series.mean`](/api-reference/series/series.mean.md)                                                                      | Return the mean of the values for the requested axis.            |
| [`Series.median`](/api-reference/series/series.median.md)                                                                  | Return the median of the values for the requested axis.          |
| [`Series.min`](/api-reference/series/series.min.md)                                                                        | Return the minimum of the values for the requested axis.         |
| [`Series.mode`](/api-reference/series/series.mode.md)                                                                      | Return the mode(s) of the dataset.                               |
| [`Series.std`](/api-reference/series/series.std.md)                                                                        | Return sample standard deviation over requested axis.            |
| [`Series.sum`](/api-reference/series/series.sum.md)                                                                        | Return the sum of the values for the requested axis.             |
| [`Series.var`](/api-reference/series/series.var.md)                                                                        | Return unbiased variance over requested axis.                    |
| [`Series.unique`](/api-reference/series/series.unique.md)                                                                  | Return unique values of Series object.                           |
| [`Series.nUnique`](/api-reference/series/series.nunique.md)                                                                | Return number of unique elements in the object.                  |
| [`Series.valueCounts`](/api-reference/series/series.value_counts.md)                                                       | Return a Series containing counts of unique values.              |

### Reindexing / selection / label manipulation

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

### Missing data handling

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

### Logical Comparison

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

### Reshaping, sorting

| [`Series.argSort`](/api-reference/series/series.argsort.md)        | Return the integer indices that would sort the Series values. |
| ------------------------------------------------------------------ | ------------------------------------------------------------- |
| [`Series.argMin`](/api-reference/series/series.argmin.md)          | Return int position of the smallest value in the Series.      |
| [`Series.argMax`](/api-reference/series/series.argmax.md)          | Return int position of the largest value in the Series.       |
| [`Series.sortValues`](/api-reference/series/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](/api-reference/general-functions/danfo.dt.md) | dt       |
| [String](/api-reference/general-functions/danfo.str.md)  | 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`](/api-reference/series/series.dt.year.md)              | The year of the datetime.                                               |
| [`Series.dt.month`](/api-reference/series/series.dt.month.md)            | Returns a numeric representation of the month. January=0 - December=11. |
| [Series.dt.monthName](/api-reference/series/series.dt.month_name.md)     |                                                                         |
| [`Series.dt.dayOfWeek`](/api-reference/series/series.dt.day.md)          | Returns the day of the week, in local time                              |
| [`Series.dt.hour`](/api-reference/series/series.dt.hour.md)              | The hours of the datetime.                                              |
| [`Series.dt.minute`](/api-reference/series/series.dt.minute.md)          | The minutes of the datetime.                                            |
| [`Series.dt.second`](/api-reference/series/series.dt.second.md)          | The seconds of the datetime.                                            |
| [`Series.dt.dayOfWeekName`](/api-reference/series/series.dt.weekdays.md) | Returns the name of the day, of the week, in local time                 |
| [`Series.dt.dayOfMonth`](/api-reference/series/series.dt.month_name.md)  | 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`](/api-reference/series/series.str.capitalize.md)   | Capitalize the first character of each string                                                                                  |
| --------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
| [`Series.str.toUpperCase`](/api-reference/series/series.str.touppercase.md) | Converts all characters to uppercase.                                                                                          |
| [`Series.str.toLowerCase`](/api-reference/series/series.str.tolowercase.md) | Converts all characters to lowercase.                                                                                          |
| [`Series.str.charAt`](/api-reference/series/series.str.charat.md)           | Returns the character at the specified index (position).                                                                       |
| [`Series.str.concat`](/api-reference/series/series.str.concat.md)           | Joins two or more strings/arrays.                                                                                              |
| [`Series.str.startsWith`](/api-reference/series/series.str.startswith.md)   | Checks whether a string begins with specified characters.                                                                      |
| [`Series.str.endsWith`](/api-reference/series/series.str.endswith.md)       | Checks whether a string ends with specified characters                                                                         |
| [`Series.str.includes`](/api-reference/series/series.str.includes.md)       | Checks whether a string contains the specified string/characters.                                                              |
| [`Series.str.indexOf`](/api-reference/series/series.str.indexof.md)         | Returns the position of the first found occurrence of a specified value in a string.                                           |
| [`Series.str.lastIndexOf`](/api-reference/series/series.str.lastindexof.md) | Returns the position of the last found occurrence of a specified value in a string.                                            |
| [`Series.str.repeat`](/api-reference/series/series.str.repeat.md)           | Returns a new string with a specified number of copies of an existing string.                                                  |
| [`Series.str.search`](/api-reference/series/series.str.search.md)           | Searches a string for a specified value, or regular expression, and returns the position of the match.                         |
| [`Series.str.slice`](/api-reference/series/series.str.slice.md)             | Extracts a part of a string and returns a new string.                                                                          |
| [`Series.str.split`](/api-reference/series/series.str.split.md)             | Splits a string into an array of substrings.                                                                                   |
| [`Series.str.substr`](/api-reference/series/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`](/api-reference/series/series.str.substring.md)     | Extracts the characters from a string, between two specified indices.                                                          |
| [`Series.str.len`](/api-reference/series/series.str.len.md)                 | Counts the number of characters in each string.                                                                                |
| [`Series.str.trim`](/api-reference/series/series.str.trim.md)               | Removes whitespace from both ends of a string.                                                                                 |
| [`Series.str.join`](/api-reference/series/series.str.join.md)               | Joins strings to specified value.                                                                                              |
| [`Series.str.replace`](/api-reference/series/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.<kind>`.

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

### Serialization / IO / conversion

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