df_apply_to_column Subroutine

public subroutine df_apply_to_column(df, col_index, func)

Apply custom function to column

Applies a user-defined transformation function to each element in the column

@param[in,out] df The data frame instance @param[in] col_index Index of the column @param[in] func Function to apply (must match transform_func interface)

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(inout) :: df
integer, intent(in) :: col_index
procedure(transform_func) :: func

Source Code

    subroutine df_apply_to_column(df, col_index, func)
        type(data_frame), intent(inout) :: df
        integer, intent(in) :: col_index
        procedure(transform_func) :: func

        real(rk), dimension(:), allocatable :: col
        integer :: i

        col = df_get_col_real(df, col_index)
        do i = 1, size(col)
            col(i) = func(col(i))
        end do
        call df_set_col_real(df, col_index, col)
    end subroutine df_apply_to_column