def METHOD_NAME(events):
    # Column checks
    for col_name in ["onset", "duration"]:
        if col_name not in events.columns:
            raise ValueError(
                f"The provided events data has no {col_name} column."
            )
        if events[col_name].isnull().any():
            raise ValueError(
                f"The following column must not contain nan values: {col_name}"
            )
        # Make sure we have a numeric type for duration
        if not is_numeric_dtype(events[col_name]):
            try:
                events = events.astype({col_name: float})
            except ValueError as e:
                raise ValueError(
                    f"Could not cast {col_name} to float in events data."
                ) from e
    return events