datafort_manipulation Module

DataFort Manipulation Module

This module provides standalone functions for data frame manipulation operations. All functions take a data_frame as the first argument instead of being type-bound procedures.

Functions

Selection and Slicing

  • df_select_columns(df, column_indices) - Extract subset of columns
  • df_slice_rows(df, start_row, end_row) - Extract row range

Filtering

  • df_filter_rows_logical(df, logical_col_index) - Filter rows by logical column
  • df_filter_rows_real_range(df, col_index, min_val, max_val) - Filter rows by real value range
  • df_filter_rows_integer_range(df, col_index, min_val, max_val) - Filter rows by integer value range
  • df_filter_rows_string_pattern(df, col_index, pattern) - Filter rows by string pattern

Copy and Transform

  • df_copy(df) - Create a deep copy of the data frame
  • df_transpose(df) - Transpose the data frame (converts to character)

Column Manipulation

  • df_rename_column(df, col_index, new_name) - Rename a column
  • df_drop_column(df, col_index) - Remove a column
  • df_reorder_columns(df, new_order) - Reorder columns


Functions

public function df_copy(df) result(new_df)

Create a deep copy of a data frame

Read more…

Arguments

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

Return Value type(data_frame)

public function df_filter_rows_integer_range(df, col_index, min_val, max_val) result(filtered_df)

Filter rows by integer value range

Read more…

Arguments

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

Return Value type(data_frame)

public function df_filter_rows_logical(df, logical_col_index) result(new_df)

Filter rows based on a logical column

Read more…

Arguments

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

Return Value type(data_frame)

public function df_filter_rows_real_range(df, col_index, min_val, max_val) result(filtered_df)

Filter rows by real value range

Read more…

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df
integer, intent(in) :: col_index
real(kind=rk), intent(in) :: min_val
real(kind=rk), intent(in) :: max_val

Return Value type(data_frame)

public function df_filter_rows_string_pattern(df, col_index, pattern) result(filtered_df)

Filter rows by string pattern

Read more…

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df
integer, intent(in) :: col_index
character(len=*), intent(in) :: pattern

Return Value type(data_frame)

public function df_isin_character(df, col_index, values) result(mask)

Check if character values are in a given list

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df
integer, intent(in) :: col_index
character(len=*), intent(in), dimension(:) :: values

Return Value logical, dimension(:), allocatable

public function df_isin_integer(df, col_index, values) result(mask)

Check if integer values are in a given list

Arguments

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

Return Value logical, dimension(:), allocatable

public function df_isin_real(df, col_index, values) result(mask)

Check if real values are in a given list

Read more…

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(in) :: df
integer, intent(in) :: col_index
real(kind=rk), intent(in), dimension(:) :: values

Return Value logical, dimension(:), allocatable

public function df_select_columns(df, column_indices) result(new_df)

Select specific columns from a data frame

Read more…

Arguments

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

Return Value type(data_frame)

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

Slice rows to create a new data frame

Read more…

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_transpose(df) result(transposed_df)

Transpose a data frame

Read more…

Arguments

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

Return Value type(data_frame)


Subroutines

private subroutine copy_column_to_df(source_df, col_index, target_df)

Helper subroutine to copy a column from one dataframe to another

Arguments

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

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

Helper subroutine to copy filtered rows for a single column

Read more…

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_drop_column(df, col_index)

Drop a column from the data frame

Read more…

Arguments

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

public subroutine df_insert_column_character(df, data, position, header)

Insert a character column at a specific position

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(inout) :: df
character(len=*), intent(in), dimension(:) :: data
integer, intent(in) :: position
character(len=*), intent(in), optional :: header

public subroutine df_insert_column_complex(df, data, position, header)

Insert a complex column at a specific position

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(inout) :: df
complex(kind=rk), intent(in), dimension(:) :: data
integer, intent(in) :: position
character(len=*), intent(in), optional :: header

public subroutine df_insert_column_integer(df, data, position, header)

Insert an integer column at a specific position

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(inout) :: df
integer(kind=ik), intent(in), dimension(:) :: data
integer, intent(in) :: position
character(len=*), intent(in), optional :: header

public subroutine df_insert_column_logical(df, data, position, header)

Insert a logical column at a specific position

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(inout) :: df
logical, intent(in), dimension(:) :: data
integer, intent(in) :: position
character(len=*), intent(in), optional :: header

public subroutine df_insert_column_real(df, data, position, header)

Insert a real column at a specific position

Read more…

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(inout) :: df
real(kind=rk), intent(in), dimension(:) :: data
integer, intent(in) :: position
character(len=*), intent(in), optional :: header

public subroutine df_rename_column(df, col_index, new_name)

Rename a column in the data frame

Read more…

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(inout) :: df
integer, intent(in) :: col_index
character(len=*), intent(in) :: new_name

public subroutine df_reorder_columns(df, new_order)

Reorder columns in the data frame

Read more…

Arguments

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