df_fillna_integer Subroutine

public subroutine df_fillna_integer(df, col_index, fill_value)

Replace NaN values in an integer column with a fill value

Replaces all NaN sentinel values in the specified column with the given value

@param[in,out] df The data frame instance @param[in] col_index Column index to fill @param[in] fill_value Value to replace NaN with

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(inout) :: df
integer, intent(in) :: col_index
integer(kind=ik), intent(in) :: fill_value

Source Code

    subroutine df_fillna_integer(df, col_index, fill_value)
        type(data_frame), intent(inout) :: df
        integer, intent(in) :: col_index
        integer(ik), intent(in) :: fill_value

        integer(ik), dimension(:), allocatable :: col
        integer :: i

        if (col_index < 1 .or. col_index > df % ncols()) error stop "column index out of range"

        col = df_get_col_integer(df, col_index)

        do i = 1, size(col)
            if (is_nan_integer(col(i))) then
                col(i) = fill_value
            end if
        end do

        call df_set_col_integer(df, col_index, col)
    end subroutine df_fillna_integer