Through the needs of a different project that I am working on, I have created a library that implements a data frame data structure called fortranDF (fortran Data Frames):
The idea is to be somewhat similar to the data frames found in Pandas and R, where the data is column-based. Each column can be a different intrinsic type, but all data within a column must be of the same type. Each column also can have a header, which can be used to retrieve the column associated to said header.
Here is some example code that builds a data frame with an integer column and a real column and prints the whole data frame to the screen:
program example
use iso_fortran_env,only: OUTPUT_UNIT
use df_precision,only: rk
use df_fortranDF,only: data_frame
implicit none
type(data_frame) :: df
call df%new()
call df%append([1.0_rk,2.0_rk,3.0_rk],"real_data")
call df%append([1,2,3],"integer_data")
call df%write(OUTPUT_UNIT)
end program example
Right now the library is just the data container/structure, with some very limited IO procedures (write to screen and read from a file with a very specific format). I hope to change this in the future (ideally add at least support for CSV format) but for now IO is delegated to the user with the use of extended types.
As an example for extending the data_frame
type, I have also made fortranMR (fortran MESA reader) public, which is a very bare bones and unpolished library for reading in a type of file that the stellar evolution program MESA outputs. fortranMR is really for my own use, but it happens to also serve as decent example of making user-defined extensions to the data_frame
type.
I am interested to hear any feedback for anything about this project, including feature ideas, code criticism, documentation, or even whether or not you think this would be useful to use.