## DEV Community is a community of 890,060 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

# What are outliers?

Outliers are data points that are far from most of the other data points.

In this example of time series, all the points outside the blue band can be considered as outliers. # How to get a list of outliers in a time series?

Here we will use a library called tsmoothie.
It is a python library for time-series smoothing and outlier detection in a vectorized way.

On the time series in the figure: we can see that we have 4 outliers, we can get them by:

``````

import numpy as np
from tsmoothie.utils_func import sim_randomwalk
from tsmoothie.smoother import LowessSmoother

data = df['value'].values.reshape(1, -1)

# operate smoothing
smoother = LowessSmoother(smooth_fraction=0.1, iterations=1)
smoother.smooth(data)

# generate intervals
low, up = smoother.get_intervals('prediction_interval')

points = smoother.data
up_points = up
low_points = low

for i in range(len(points)-1, 0, -1):
current_point = points[i]
current_up = up_points[i]
current_low = low_points[i]
if current_point > current_up or current_point < current_low:
print(f'found an outlier value: {current_point}')
``````

Considering that the data frame df has a column named 'value'.
So, we get this output after running the code: 