datafort_utilities Module

DataFort Utilities Module

This module provides utility procedures for data frame operations including: - Data inspection: head, tail, shape, info, empty - Data manipulation: clear, sample, shuffle - Row operations: apply_to_row_real, apply_to_all_rows_real

All procedures are standalone functions prefixed with df_.



Abstract Interfaces

abstract interface

  • public function pipe_func(df_in) result(df_out)

    Arguments

    Type IntentOptional Attributes Name
    type(data_frame), intent(in) :: df_in

    Return Value type(data_frame)

abstract interface

  • public function row_func_real(row_values, num_cols) result(output)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(in), dimension(:) :: row_values
    integer, intent(in) :: num_cols

    Return Value real(kind=rk)


Functions

public function df_apply_to_all_rows_real(df, func) result(outputs)

Apply a function to all rows

Read more…

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df
procedure(row_func_real) :: func

Return Value real(kind=rk), dimension(:), allocatable

public function df_apply_to_row_real(df, row_idx, func) result(output)

Apply a function to a specific row

Read more…

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df
integer, intent(in) :: row_idx
procedure(row_func_real) :: func

Return Value real(kind=rk)

public pure function df_empty(df) result(is_empty)

Check if dataframe is empty (no rows or no columns)

Read more…

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df

Return Value logical

public function df_equals(df1, df2) result(is_equal)

Check if two dataframes are identical

Read more…

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df1
type(data_frame), intent(in) :: df2

Return Value logical

public function df_head(df, n) result(head_df)

Return first n rows as a new dataframe

Read more…

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df
integer, intent(in), optional :: n

Return Value type(data_frame)

public function df_nlargest_integer(df, n, col_index) result(result_df)

Return dataframe with n largest values in an integer column

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df
integer, intent(in) :: n
integer, intent(in) :: col_index

Return Value type(data_frame)

public function df_nlargest_real(df, n, col_index) result(result_df)

Return dataframe with n largest values in a real column

Read more…

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df
integer, intent(in) :: n
integer, intent(in) :: col_index

Return Value type(data_frame)

public function df_nsmallest_integer(df, n, col_index) result(result_df)

Return dataframe with n smallest values in an integer column

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df
integer, intent(in) :: n
integer, intent(in) :: col_index

Return Value type(data_frame)

public function df_nsmallest_real(df, n, col_index) result(result_df)

Return dataframe with n smallest values in a real column

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df
integer, intent(in) :: n
integer, intent(in) :: col_index

Return Value type(data_frame)

public function df_pipe(df, func) result(result_df)

Apply a custom function to a dataframe (for method chaining)

Read more…

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df
procedure(pipe_func) :: func

Return Value type(data_frame)

public function df_sample(df, n, seed) result(sampled_df)

Get n random rows from the dataframe

Read more…

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df
integer, intent(in) :: n
integer, intent(in), optional :: seed

Return Value type(data_frame)

public function df_shape(df) result(dims)

Return shape as [nrows, ncols]

Read more…

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df

Return Value integer, dimension(2)

private function df_slice_rows(df, start_row, end_row) result(new_df)

Internal: Slice rows to create a new data frame

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df
integer, intent(in) :: start_row
integer, intent(in) :: end_row

Return Value type(data_frame)

public function df_tail(df, n) result(tail_df)

Return last n rows as a new dataframe

Read more…

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df
integer, intent(in), optional :: n

Return Value type(data_frame)

public function df_to_array_real(df) result(array)

Convert dataframe to 2D real array

Read more…

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df

Return Value real(kind=rk), dimension(:, :), allocatable


Subroutines

private subroutine copy_filtered_column(source_df, target_df, col_index, selected_rows)

Internal: Copy filtered column from source to target

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: source_df
type(data_frame), intent(inout) :: target_df
integer, intent(in) :: col_index
integer, intent(in), dimension(:) :: selected_rows

public subroutine df_clear(df)

Clear the dataframe (destroy and re-initialize)

Read more…

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(inout) :: df

public subroutine df_info(df, unit)

Print information about the dataframe

Read more…

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df
integer, intent(in), optional :: unit

public subroutine df_shuffle(df, seed)

Shuffle all rows randomly in place

Read more…

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(inout) :: df
integer, intent(in), optional :: seed

private subroutine reorder_all_columns(df, indices)

Internal: Reorder all columns according to index array

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(inout) :: df
integer, intent(in), dimension(:) :: indices