DataFrame
typedef struct {
double *data;
int numRows;
int numCols;
char **featureNames;
} DataFrame;
Represents a matrix with names for each column.
Data is stored as a row-major flattened array.
info
Added in version 0.0.0
Struct Members
double* data← Flattened arrayint numRows← Number of rows (samples)int numCols← Number of columns (features) per rowchar** featureNames← Array of column/feature names
Related Functions
-
DF_addColumn→int
Adds a single column/feature to an existing DataFrame.
Params:DataFrame* dfdouble* datachar* name -
DF_free→void
Frees all allocated memory by the DataFrame.
Params:DataFrame* df -
DF_fromArray→DataFrame*
Creates a DataFrame with one feature from the given array.
Params:double* dataint numRowschar* name
Example
#include <ml-in-c/datatypes/dataframe.h>
int main() {
// Create from array
double data[] = {1, 2, 3};
DataFrame *df = DF_fromArray(data, 3, "feature1");
// Add a column
double newData[] = {4, 5, 6};
DF_addColumn(df, newData, "feature2");
// Free array from memory
DF_free(df);
return 0;
}