datafort_transformations Module

DataFort Transformations Module

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

Functions

Normalization/Standardization

  • df_normalize_column_real(df, col_index) - Normalize to [0,1] range
  • df_standardize_column_real(df, col_index) - Standardize to mean=0, std=1

Absolute Value

  • df_abs_column_real(df, col_index) - Absolute value for real column
  • df_abs_column_integer(df, col_index) - Absolute value for integer column

Cumulative Sum

  • df_cumsum_real(df, col_index) - Cumulative sum for real column
  • df_cumsum_integer(df, col_index) - Cumulative sum for integer column

Differences

  • df_diff_real(df, col_index) - Differences between consecutive rows (real)
  • df_diff_integer(df, col_index) - Differences between consecutive rows (integer)

Value Replacement

  • df_replace_value_real(df, col_index, old_value, new_value) - Replace values in real column
  • df_replace_value_integer(df, col_index, old_value, new_value) - Replace values in integer column

Clipping

  • df_clip_real(df, col_index, min_val, max_val) - Clip real values to range
  • df_clip_integer(df, col_index, min_val, max_val) - Clip integer values to range

Rounding

  • df_round_column(df, col_index, decimals) - Round to decimal places

Mathematical Functions

  • df_log_column(df, col_index) - Natural logarithm
  • df_exp_column(df, col_index) - Exponential
  • df_sqrt_column(df, col_index) - Square root
  • df_pow_column(df, col_index, power) - Raise to power

Custom Transformation

  • df_apply_to_column(df, col_index, func) - Apply custom function


Abstract Interfaces

abstract interface

  • public pure function transform_func(x) result(y)

    Arguments

    Type IntentOptional Attributes Name
    real(kind=rk), intent(in) :: x

    Return Value real(kind=rk)


Functions

private function calculate_max_real(df, col_index) result(max_val)

Calculate maximum of a real column

Arguments

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

Return Value real(kind=rk)

private function calculate_mean_real(df, col_index) result(avg)

Calculate mean of a real column

Arguments

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

Return Value real(kind=rk)

private function calculate_min_real(df, col_index) result(min_val)

Calculate minimum of a real column

Arguments

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

Return Value real(kind=rk)

private function calculate_std_real(df, col_index) result(stddev)

Calculate standard deviation of a real column

Arguments

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

Return Value real(kind=rk)

public function df_diff_integer(df, col_index) result(differences)

Calculate differences between consecutive rows (result has n-1 elements)

Read more…

Arguments

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

Return Value integer(kind=ik), dimension(:), allocatable

public function df_diff_real(df, col_index) result(differences)

Calculate differences between consecutive rows (result has n-1 elements)

Read more…

Arguments

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

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


Subroutines

public subroutine df_abs_column_integer(df, col_index)

Take absolute value of all elements in an integer column

Read more…

Arguments

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

public subroutine df_abs_column_real(df, col_index)

Take absolute value of all elements in a real column

Read more…

Arguments

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

public subroutine df_apply_to_column(df, col_index, func)

Apply custom function to column

Read more…

Arguments

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

public subroutine df_clip_integer(df, col_index, min_val, max_val)

Clip (clamp) values in an integer column to [min_val, max_val]

Read more…

Arguments

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

public subroutine df_clip_real(df, col_index, min_val, max_val)

Clip (clamp) values in a real column to [min_val, max_val]

Read more…

Arguments

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

public subroutine df_cumsum_integer(df, col_index)

Calculate cumulative sum for an integer column (modifies in place)

Read more…

Arguments

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

public subroutine df_cumsum_real(df, col_index)

Calculate cumulative sum for a real column (modifies in place)

Read more…

Arguments

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

public subroutine df_exp_column(df, col_index)

Apply exponential to column

Read more…

Arguments

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

public subroutine df_log_column(df, col_index)

Apply natural logarithm to column

Read more…

Arguments

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

public subroutine df_normalize_column_real(df, col_index)

Normalize a real column to [0, 1] range

Read more…

Arguments

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

public subroutine df_pow_column(df, col_index, power)

Raise column to a power

Read more…

Arguments

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

public subroutine df_replace_value_integer(df, col_index, old_value, new_value)

Replace all occurrences of a value in an integer column

Read more…

Arguments

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

public subroutine df_replace_value_real(df, col_index, old_value, new_value)

Replace all occurrences of a value in a real column

Read more…

Arguments

Type IntentOptional Attributes Name
type(data_frame), intent(inout) :: df
integer, intent(in) :: col_index
real(kind=rk), intent(in) :: old_value
real(kind=rk), intent(in) :: new_value

public subroutine df_round_column(df, col_index, decimals)

Round real column to specified number of decimal places

Read more…

Arguments

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

public subroutine df_sqrt_column(df, col_index)

Apply square root to column

Read more…

Arguments

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

public subroutine df_standardize_column_real(df, col_index)

Standardize a real column (z-score: mean=0, std=1)

Read more…

Arguments

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