@pandas_udf(features_schema, PandasUDFType.GROUPED_MAP)
def get_corr_mse_features_udf(df):
    timestamp = df['timestamp'].iloc[0]
    localtime = df['localtime'].iloc[0]
    user = df['user'].iloc[0]
    version = df['version'].iloc[0]
    start_time = timestamp
    end_time = df['timestamp'].iloc[(- 1)]
    ax_ay_corr = df[accel_column_names[0]].corr(df[accel_column_names[1]])
    ax_az_corr = df[accel_column_names[0]].corr(df[accel_column_names[2]])
    ay_az_corr = df[accel_column_names[1]].corr(df[accel_column_names[2]])
    gx_gy_corr = df[gyro_column_names[0]].corr(df[gyro_column_names[1]])
    gx_gz_corr = df[gyro_column_names[0]].corr(df[gyro_column_names[2]])
    gy_gz_corr = df[gyro_column_names[1]].corr(df[gyro_column_names[2]])
    ax_ay_mse = ((df[accel_column_names[0]] - df[accel_column_names[1]]) ** 2).mean()
    ax_az_mse = ((df[accel_column_names[0]] - df[accel_column_names[2]]) ** 2).mean()
    ay_az_mse = ((df[accel_column_names[1]] - df[accel_column_names[2]]) ** 2).mean()
    gx_gy_mse = ((df[accel_column_names[0]] - df[accel_column_names[1]]) ** 2).mean()
    gx_gz_mse = ((df[accel_column_names[0]] - df[accel_column_names[2]]) ** 2).mean()
    gy_gz_mse = ((df[accel_column_names[1]] - df[accel_column_names[2]]) ** 2).mean()
    basic_df = pd.DataFrame([[timestamp, localtime, user, int(version), start_time, end_time, ax_ay_corr, ax_az_corr, ay_az_corr, gx_gy_corr, gx_gz_corr, gy_gz_corr, ax_ay_mse, ax_az_mse, ay_az_mse, gx_gy_mse, gx_gz_mse, gy_gz_mse]], columns=['timestamp', 'localtime', 'user', 'version', 'start_time', 'end_time', 'ax_ay_corr', 'ax_az_corr', 'ay_az_corr', 'gx_gy_corr', 'gx_gz_corr', 'gy_gz_corr', 'ax_ay_mse', 'ax_az_mse', 'ay_az_mse', 'gx_gy_mse', 'gx_gz_mse', 'gy_gz_mse'])
    return basic_df
@pandas_udf(features_schema, PandasUDFType.GROUPED_MAP)
def get_corr_mse_features_udf(df):
    timestamp = df['timestamp'].iloc[0]
    localtime = df['localtime'].iloc[0]
    user = df['user'].iloc[0]
    version = df['version'].iloc[0]
    start_time = timestamp
    end_time = df['timestamp'].iloc[(- 1)]
    ax_ay_corr = df[accel_column_names[0]].corr(df[accel_column_names[1]])
    ax_az_corr = df[accel_column_names[0]].corr(df[accel_column_names[2]])
    ay_az_corr = df[accel_column_names[1]].corr(df[accel_column_names[2]])
    gx_gy_corr = df[gyro_column_names[0]].corr(df[gyro_column_names[1]])
    gx_gz_corr = df[gyro_column_names[0]].corr(df[gyro_column_names[2]])
    gy_gz_corr = df[gyro_column_names[1]].corr(df[gyro_column_names[2]])
    ax_ay_mse = ((df[accel_column_names[0]] - df[accel_column_names[1]]) ** 2).mean()
    ax_az_mse = ((df[accel_column_names[0]] - df[accel_column_names[2]]) ** 2).mean()
    ay_az_mse = ((df[accel_column_names[1]] - df[accel_column_names[2]]) ** 2).mean()
    gx_gy_mse = ((df[accel_column_names[0]] - df[accel_column_names[1]]) ** 2).mean()
    gx_gz_mse = ((df[accel_column_names[0]] - df[accel_column_names[2]]) ** 2).mean()
    gy_gz_mse = ((df[accel_column_names[1]] - df[accel_column_names[2]]) ** 2).mean()
    basic_df = pd.DataFrame([[timestamp, localtime, user, int(version), start_time, end_time, ax_ay_corr, ax_az_corr, ay_az_corr, gx_gy_corr, gx_gz_corr, gy_gz_corr, ax_ay_mse, ax_az_mse, ay_az_mse, gx_gy_mse, gx_gz_mse, gy_gz_mse]], columns=['timestamp', 'localtime', 'user', 'version', 'start_time', 'end_time', 'ax_ay_corr', 'ax_az_corr', 'ay_az_corr', 'gx_gy_corr', 'gx_gz_corr', 'gy_gz_corr', 'ax_ay_mse', 'ax_az_mse', 'ay_az_mse', 'gx_gy_mse', 'gx_gz_mse', 'gy_gz_mse'])
    return basic_df