import numpy as np
import pandas as pd


def to_numpy_1d(data):
    """
    Convert list, NumPy array, or Pandas Series into a 1-D NumPy array.
    Removes NaN values.

    Parameters
    ----------
    data : list, numpy.ndarray, or pandas.Series

    Returns
    -------
    numpy.ndarray
        Clean one-dimensional numeric array.
    """

    if isinstance(data, pd.Series):
        x = data.dropna().values

    elif isinstance(data, (list, tuple)):
        x = np.array(data, dtype=float)

    elif isinstance(data, np.ndarray):
        x = data.astype(float)

    else:
        raise TypeError(
            "Data must be a list, NumPy array, or Pandas Series."
        )

    x = x[~np.isnan(x)]

    if x.ndim != 1:
        raise ValueError("Input data must be one-dimensional.")

    if len(x) < 3:
        raise ValueError("At least 3 observations are required.")

    return x