def linear_interpolation(data, threshold):
    """
	Function to interpolate missing values for 'x' and 'y' attributes
	in dataset.
	'threshold' parameter decides the number of rows till which, data
	should NOT be deleted.

	Input- Accepts Pandas DataFrame
	Returns- Processed Pandas DataFrame
	"""
    missing_x_values = list(data[data['x'].isnull()].index)
    missing_y_values = list(data[data['y'].isnull()].index)
    print("\nNumber of missing values in 'x' attribute = {0}".format(len(
        missing_x_values)))
    print("Number of missing values in 'y' attribute = {0}\n".format(len(
        missing_y_values)))
    i = 0
    j = 0
    start = end = 0
    k = 1
    indices_to_delete = []
    while i < len(missing_x_values) - 1:
        start = end = missing_x_values[i]
        k = 1
        j = i
        while j < len(missing_x_values) - 1:
            if missing_x_values[j] + 1 == missing_x_values[j + 1]:
                k += 1
                j += 1
                end = missing_x_values[j]
            else:
                break
        i = j + 1
        if k >= threshold:
            print('\nDelete sequence from {0} to {1}\n'.format(start, end))
            for x in range(start, end + 1):
                indices_to_delete.append(x)
        elif k > 1:
            print('\nSequence length = {0}. Start = {1} & End = {2}'.format
                (k, start, end))
    data_del = data.drop(data.index[indices_to_delete], axis=0)
    return data_del
