Docs
.cols

Dataframe.cols

This function returns specific columns of the dataframe strictly using interger based indexing similar to panda's iloc, this function takes an object with either the start or the end index and return the dataframe with the specified columns

Parameter

  • Indexer.start?: number - if provided, specifies the begin, or else default to the first column in the dataframe
  • Indexer.end?: number - if provided, specifies the end, or else default to the last column in the dataframe

Returns

  • Dataframe

The example below returns the first 4 columns, starting from index 0

const count: Dataframe<T> = df.cols({ start: 0, end: 4 });

The example below returns the specified columns starting from the second column and the next three columns

const count: Dataframe<T> = df.cols({ start: 1, end: 4 });

Let's say you want the dataframe to have none of the columns except the last column of the dataframe, making the value of end, -1 returns the last column of the dataframe with the rest omitted, and intuitively, making the value of end, -2 returns the lasts two columns and so on.

const count: Dataframe<T> = df.cols({ end: -1 });

Not providing the start and end value will by default returns the entire columns of the dataframe

const count: Dataframe<T> = df.cols({});