In memory tabular data handling library

When I returned to Xojo, after on long time spent with Python and Pandas, I started to miss Pandas. Although far from perfect, the pandas library provides a convenient support for in memory storage of tabular data. We can obviously achieve the same function with in-memory sqlite but then many errors are only caught at execution time.

So, I tried to create a minimal ‘pandas inspired’ (not a pandas clone) library with Xojo for a new personal project built with Xojo.

The data are stored in columns, so a table is an array of columns and a column is an array of values. The table object is responsible for maintaining a consistent number of elements across columns.

Since the community helped me in the past, I though I should share that lib with the community, so I tried to improve code readability, added minimum documentation and pushed the results to a public repo in GitHub.

In case you want to give it a try, you can find the library with examples and test cases in: GitHub - slo1958/sl-xj-lib-data: Data handling library.

Background

Retired software engineer. Started to use Xojo when it was still called ‘CrossBasic’, mainly for personal projects. Later, used RealBasic for Windows for professional projects. I used Python during my last working years.

3 Likes

Here is an example solution for a question posted on the forum, using the library.
The question is
“I have 2 related arrays of data. I would like to list the sales, grouped by category id. I need to group the sales per category”

Here is an example solution using the data library:

var SourceTable as new clDataTable("MyTable")

call SourceTable.AddColumn(new clStringDataSerie("Category", Array("3", "1", "3", "2", "1", "2", "3", "2") ))
call SourceTable.AddColumn(new clNumberDataSerie("Sales", Array(20.00, 10.00, 30.00, 25.00, 15.00, 10.00, 20.00, 8.00) ))

var GroupedTable as clDataTable = SourceTable.Groupby(array("Category"), array("Sales"))

for each row as clDataRow in GroupedTable
  
  System.DebugLog("CategoryGroup=" + row.GetCell("Category") + " Sales = " + format(row.GetCell("Sum of Sales").DoubleValue, "-####0.###"))
  
next
1 Like