Print information about the dataframe
@param[in] df The data frame @param[in] unit Optional output unit (default: stdout)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(data_frame), | intent(in) | :: | df | |||
integer, | intent(in), | optional | :: | unit |
subroutine df_info(df, unit) type(data_frame), intent(in) :: df integer, intent(in), optional :: unit integer :: out_unit, i, dtype character(len=20) :: type_name integer, dimension(2) :: dims if (present(unit)) then out_unit = unit else out_unit = 6 ! stdout end if dims = df_shape(df) write (out_unit, '(a)') repeat('=', 60) write (out_unit, '(a)') 'DataFrame Information' write (out_unit, '(a)') repeat('=', 60) write (out_unit, '(a,i0,a,i0,a)') 'Shape: (', dims(1), ' rows, ', dims(2), ' columns)' write (out_unit, '(a,l1)') 'Has headers: ', df % get_with_headers() if (df % ncols() > 0) then write (out_unit, '(a)') '' write (out_unit, '(a)') 'Columns:' write (out_unit, '(a)') repeat('-', 60) do i = 1, df % ncols() dtype = df % dtype(i) select case (dtype) case (REAL_NUM) type_name = 'real' case (INTEGER_NUM) type_name = 'integer' case (LOGICAL_NUM) type_name = 'logical' case (CHARACTER_NUM) type_name = 'character' case (COMPLEX_NUM) type_name = 'complex' case default type_name = 'unknown' end select if (df % get_with_headers()) then write (out_unit, '(i4,2a,t30,3a)') i, '. ', trim(df % header(i)), & '(', trim(type_name), ')' else write (out_unit, '(i4,2a,a)') i, '. Column (', trim(type_name), ')' end if end do end if write (out_unit, '(a)') repeat('=', 60) end subroutine df_info