This project is a library with dataframes implementation. Dataframes are structures allowing more comfortable work with big datasets.
Environment | Build status |
---|---|
CI Build (macOS, Linux, Windows) |
Required dependencies:
matplotlib
seaborn
Optional dependencies: These dependencies are not required to compile the helper library, however without them certain functionalities shall be disabled.
conda create -n dataframes python=3.6
conda activate dataframes
conda install arrow-cpp=0.10.* -c conda-forge
conda install pyarrow=0.10.* -c conda-forge
conda install rapidjson
native_libs/src/CMakeLists.txt
:
set(CMAKE_LIBRARY_PATH "/anaconda3/envs/dataframes/lib")
set(CMAKE_INCLUDE_PATH "/anaconda3/envs/dataframes/include")
And you should be all set.
luna
should out-of-the-box be able to find it.
cd Dataframes\native_libs
mkdir build
cd build
cmake -G"NMake Makefiles" ..\src
nmake
cd Dataframes/native_libs
mkdir build
cd build
cmake ../src
make
where Dataframes
refer to the local copy of this repo.
The library currently provides wrappers for Apache Arrow structures.
ArrayData
— type-erased storage for Array
consisting of several contiguous memory buffers. The buffer count depends on stored type. Typically there are two buffers: one for values and one for masking nulls. More comples types (union, lists) will use more.Array tag
— data array with strongly typed accessors. See section below for supported tag
types.ChunkedArray tag
— a list of Array
s of the same type viewed as a single large array. Allows storing large sequences of data (that could not be feasably stored in a single memory block) and efficient slice / concat operations.Column
— type erased accessor for a named ChunkedArray
. Stored type is represented by using one of its constructors. Described by Field
.Table
— ordered sequence of Column
s. Described by Schema
.These types are provided by the library to identify types that can be stored by Array
and their mapping to Luna types. Currently provided type tags are listed in the table below.
Tag type | Luna value type | Apache Arrow type | Memory per element |
---|---|---|---|
StringType | Text | utf8 non-nullable | 4 bytes + 1 byte per character + 1 bit mask |
MaybeStringType | Maybe Text | utf8 nullable | as above |
Int64Type | Int | int64 non-nullable | 8 bytes + 1 bit mask |
MaybeInt64Type | Maybe Int | int64 nullable | as above |
DoubleType | Real | double non-nullable | 8 bytes + 1 bit mask |
MaybeDoubleType | Maybe Real | double nullable | as above |
Note: Arrow's utf8
type is a list of non-nullable bytes.
CSV and Feather files are supported. XLSX files are supported if the helper C++ library was built with XLNT third-part library enabled.
Format | Parser Type | Generator Type | Remarks |
---|---|---|---|
CSV file | CSVParser |
CSVGenerator |
|
XLSX | XLSXParser |
XLSXGenerator |
Requires optional XLNT library |
Feather | FeatherParser |
FeatherGenerator |
Best performance, not all value types are currently supported |
Parser type shall provide the following method:
readFile path :: Text -> Table
Generator type shall provide the following method:writeFile path table :: Text -> Table -> IO None
Column names are by default read from the file. CSV and XLSX parsers can also work with files that do not contain the reader row. In such case one of the methods below should be called:
useCustomNames names
where names :: [Text]
are user-provided list of desired column names. If there are more columns in file than names count, then more names will be generated.useGeneratedColumnNames
— all column names will be automatically generated (and the first row will be treated as containing values).Similarly, the CSV and XLSX generators can be configured whether to output a heading row with names.
setHeaderPolicy WriteHeaderLine
or setHeaderPolicy SkipHeaderLine
The CSV generator can be also configured whether the fields should be always enclosed within quotes or whether this should be done only when necessary (the latter being the default):
setQuotingPolicy QuoteWhenNeeded
or setQuotingPolicy QuoteAllFields
DataType
represents the type of values being stored in a ArrayData
. Note that this type does not contain information whether it is nullable — being nullable is a property of Field
, not Datatype
.Field
is a named DataType
with an additional information whether values are nullable. Describes contents of the Column
.Schema
is a sequence of Field
s describing the Table
.corr
— calculates correlation matrix, with Pearson correlation coefficient for each column pair.corrWith columnName
— calculates Pearson correlation coefficient between given column in a table and its other columns.countValues columnName
— returns table with pairs (value, count).describeNa
— calculates count of null values and their ratio to the total row count.describe columnName
— calculates a number of statistics for a given column (mean, std, min, quartiles, max).countMissing
— returns the number of null values in the column.countValues
— counts occurences of each unique value and returns pairs (value, count).min
— minimum of values.max
— maximum of values.mean
— mean of values.median
— median of values (interpolated, if value count is even)std
— standard deviation of values.var
— variation of values.sum
— sum of values.quantile q
— value at given quantile, q belongs to <0,1>.describe
— calculates a number of statistics for a given column (mean, std, min, quartiles, max).TBD