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_.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(data_frame), | intent(in) | :: | df_in |
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| real(kind=rk), | intent(in), | dimension(:) | :: | row_values | ||
| integer, | intent(in) | :: | num_cols |
Apply a function to all rows
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(data_frame), | intent(in) | :: | df | |||
| procedure(row_func_real) | :: | func |
Apply a function to a specific row
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(data_frame), | intent(in) | :: | df | |||
| integer, | intent(in) | :: | row_idx | |||
| procedure(row_func_real) | :: | func |
Check if dataframe is empty (no rows or no columns)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(data_frame), | intent(in) | :: | df |
Check if two dataframes are identical
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(data_frame), | intent(in) | :: | df1 | |||
| type(data_frame), | intent(in) | :: | df2 |
Return first n rows as a new dataframe
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(data_frame), | intent(in) | :: | df | |||
| integer, | intent(in), | optional | :: | n |
Return dataframe with n largest values in an integer column
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(data_frame), | intent(in) | :: | df | |||
| integer, | intent(in) | :: | n | |||
| integer, | intent(in) | :: | col_index |
Return dataframe with n largest values in a real column
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(data_frame), | intent(in) | :: | df | |||
| integer, | intent(in) | :: | n | |||
| integer, | intent(in) | :: | col_index |
Return dataframe with n smallest values in an integer column
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(data_frame), | intent(in) | :: | df | |||
| integer, | intent(in) | :: | n | |||
| integer, | intent(in) | :: | col_index |
Return dataframe with n smallest values in a real column
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(data_frame), | intent(in) | :: | df | |||
| integer, | intent(in) | :: | n | |||
| integer, | intent(in) | :: | col_index |
Apply a custom function to a dataframe (for method chaining)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(data_frame), | intent(in) | :: | df | |||
| procedure(pipe_func) | :: | func |
Get n random rows from the dataframe
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(data_frame), | intent(in) | :: | df | |||
| integer, | intent(in) | :: | n | |||
| integer, | intent(in), | optional | :: | seed |
Return shape as [nrows, ncols]
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(data_frame), | intent(in) | :: | df |
Internal: Slice rows to create a new data frame
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(data_frame), | intent(in) | :: | df | |||
| integer, | intent(in) | :: | start_row | |||
| integer, | intent(in) | :: | end_row |
Return last n rows as a new dataframe
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(data_frame), | intent(in) | :: | df | |||
| integer, | intent(in), | optional | :: | n |
Convert dataframe to 2D real array
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(data_frame), | intent(in) | :: | df |
Internal: Copy filtered column from source to target
| Type | Intent | Optional | 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 |
Clear the dataframe (destroy and re-initialize)
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(data_frame), | intent(inout) | :: | df |
Print information about the dataframe
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(data_frame), | intent(in) | :: | df | |||
| integer, | intent(in), | optional | :: | unit |
Shuffle all rows randomly in place
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(data_frame), | intent(inout) | :: | df | |||
| integer, | intent(in), | optional | :: | seed |
Internal: Reorder all columns according to index array
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(data_frame), | intent(inout) | :: | df | |||
| integer, | intent(in), | dimension(:) | :: | indices |