Apply a function to all rows
Applies a user-defined function to each row in the data frame, returning an array of results.
@param[in] df The data frame @param[in] func Function to apply (must match row_func_real interface) @return Array of results, one per row
real(rk), dimension(:), allocatable :: row_sums
row_sums = df_apply_to_all_rows_real(df, row_sum)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(data_frame), | intent(in) | :: | df | |||
procedure(row_func_real) | :: | func |
function df_apply_to_all_rows_real(df, func) result(outputs) type(data_frame), intent(in) :: df procedure(row_func_real) :: func real(rk), dimension(:), allocatable :: outputs integer :: i, n_rows n_rows = df % nrows() allocate (outputs(n_rows)) do i = 1, n_rows outputs(i) = df_apply_to_row_real(df, i, func) end do end function df_apply_to_all_rows_real