def METHOD_NAME(series):
    # numpy can't handle `Int64` values, so cast to float
    if series.dtype == "Int64":
        series = series.astype("float64")
    df = pd.DataFrame({"x": series.index, "y": series.values}).dropna()
    if df.shape[0] <= 2:
        return np.nan
    if isinstance(df["x"].iloc[0], (datetime, pd.Timestamp)):
        x = convert_datetime_to_floats(df["x"])
    else:
        x = df["x"].values
    if isinstance(df["y"].iloc[0], (datetime, pd.Timestamp)):
        y = convert_datetime_to_floats(df["y"])
    elif isinstance(df["y"].iloc[0], (timedelta, pd.Timedelta)):
        y = convert_timedelta_to_floats(df["y"])
    else:
        y = df["y"].values
    x = x - x.mean()
    y = y - y.mean()
    # prevent divide by zero error
    if len(np.unique(x)) == 1:
        return 0
    # consider scipy.stats.linregress for large n cases
    coefficients = np.polyfit(x, y, 1)
    return coefficients[0]