One of the major challenges that users face when trying to do data science in Mathematica with the Wolfram Language is how to handle big data. Leaving aside the important topic of database connectivity/functionality and the handling of data too large to fit in memory, my concern here is with the issue of how to handle large data files, which are often in csv format, but which are not too large to fit into available memory.
It is well known that, due to their generality, Mathematica’s Import and Export functions are horribly slow when handling large csv files, for example:
A = RandomReal[{0, 1}, 10000000];
Export["test.csv", A] // AbsoluteTiming
{ 255.71, “test.csv”}
and
Acsv = Flatten@Import["test.csv"]; // AbsoluteTiming
{27.4954, Null}
Performance results like these leave the user with the impression that Mathematica is suitable for handling only “toy” problems, rather than the kind of large and complex data challenges faced by data scientists in the real world.
Sure, you can speed this up with ReadLine, but not by much, after doing all the string processing. And while the mx binary file format speeds up data handling enormously, it doesn’t address the issue of how to get the data into the requisite file format, other than via the WL DumpSave function - in other words, the data already has to be in a Mathematica notebook in order to write an mx file.
A major step in the right direction has been achieved through the significant effort that WR has put into implementing the HDF5 binary file format standard in the Wolfram Language. This serves two purposes: firstly, it can speed up the storage and retrieval of large datasets, by orders of magnitudes (depending on the data type); secondly, unlike Wolfram’s proprietary mx file format, HDF5 is an open source format that can store large, complex datasets that are accessible via Python, R and MatLab, as well as other languages/platforms, including Mathematica. So, working with the same dataset as before, but using HDF5 format, we get an speed-up of around 500x on the file write and around 270x on the file read:
Export["test.h5", A] // AbsoluteTiming
{0.490421, "test.h5"}
Ah5 = Import["test.h5", {"Data", 1}]; // AbsoluteTiming
{0.108682, Null}
Ah5 == A
True
So it becomes perfectly feasible to envisage a workflow in which some pre-processing of a very large dataset in csv format takes place initially in e.g. Python Pandas, the results of which are exported to a HDF5 format file for further processing in Mathematica.
It seems to me that this advance does a great deal to address some of the major concerns about using Mathematica for large data science projects. And I am not sure that users are necessarily aware of its significance, given all the hoopla over more glamorous features that tend to get all the attention in new version releases.