Skip to main content

DF_addColumn

int DF_addColumn(DataFrame *df, double *data, char *name);

Adds a single column/feature to an existing DataFrame.

info

Added in version 0.0.0

Parameters

  • DataFrame* dfPointer to the existing DataFrame to add the column on.
  • double* dataPointer to the source array containing the new data to be added.
  • char* nameName of the new column/feature.

Return

  • int 0 on success, non-zero on failure.

Example

#include <ml-in-c/datatypes/dataframe.h>

int main() {
// Create a DataFrame from an array
double data[] = {1, 2, 3};
DataFrame *df = DF_fromArray(data, 3, "feature1");

// Add a column to the existing DataFrame
double newData[] = {4, 5, 6};
DF_addColumn(df, newData, "feature2");

return 0;
}