Class DataFrame

Inheritance Relationships

Base Type

Class Documentation

class DataFrame : public nix::base::EntityWithSources<base::IDataFrame>

Public Functions

inline DataFrame()
inline DataFrame(const std::shared_ptr<base::IDataFrame> &df)
inline DataFrame(std::shared_ptr<base::IDataFrame> &&ptr)
inline ndsize_t rows() const

Returns the number of rows in the DataFrame.

Returns

The current number of rows.

inline void rows(ndsize_t n)

Resize the number of rows of the DataFrame.

Parameters

n – The new number of rows.

inline std::vector<unsigned> colIndex(const std::vector<std::string> &names) const

Resolve column names to column indices.

Parameters

names – The names to resolve.

Returns

The resolved column indices.

inline std::vector<std::string> colName(const std::vector<unsigned> &cols) const

Resolve column indices to column names.

Parameters

cols – The indices to resolve.

Returns

The resolved column names.

inline unsigned colIndex(const std::string &name) const

Resolve a column name to a column index.

Parameters

name – The name to resolve.

Returns

The resolved column index.

inline std::string colName(unsigned col) const

Resolve column index to a column name.

Parameters

col – The index to resolve.

Returns

The resolved column name.

inline std::vector<Column> columns() const

Returns the description of the columns of the DataFrame.

Returns

A std::vector containing Column objects.

inline void writeRow(ndsize_t row, const std::vector<Variant> &v)

Write a complete row, overwriting any existing data.

Parameters
  • row – Index of the row to write to.

  • v – std::vector of nix::Variant objects

inline void writeCell(ndsize_t row, unsigned col, const Variant &v)

Write a single cell.

Parameters
  • row – Index of the row to write to.

  • col – Index of the column to write to.

  • vnix::Variant containing the data.

inline void writeCells(ndsize_t row, const std::vector<Cell> &cells)

Write multiple cells of the same row.

Parameters
  • row – Index of the row to write to.

  • cells – std::vector of nix::Cell object. Either the column index or the column name must be set in the cell object.

inline Cell readCell(ndsize_t row, unsigned col) const

Read a single cell.

Parameters
  • row – Index of the row to read from.

  • colColumn index of the cell to read.

Returns

A nix::Cell with the cell’s data.

inline Cell readCell(ndsize_t row, const std::string &col) const

Read a single cell.

Parameters
  • row – Index of the row to read from.

  • colColumn name of the cell to read.

Returns

A nix::Cell with the cell’s data.

inline std::vector<Cell> readCells(ndsize_t row, const std::vector<std::string> &cols) const

Read multiple cells of the same row.

Parameters
  • row – Index of the row to read from.

  • cols – Names of the cells to read.

Returns

A std::vector of nix::Cell with the cells’ data.

inline std::vector<Variant> readRow(ndsize_t row)

Read an entire row of the DataFrame.

Parameters

row – Index of the row to read from.

Returns

A std::vector of nix::Variant containing the row data.

template<typename T>
inline void writeColumn(const std::string &name, const std::vector<T> &vals, ndsize_t offset = 0, ndsize_t count = 0)

Write column data.

Parameters
  • name – Name of the column to write.

  • vals – A std::vector with the data to write.

  • offset – Where to start.

  • count – How many columns to write.

template<typename T>
inline void writeColumn(unsigned col, const std::vector<T> &vals, ndsize_t offset = 0, ndsize_t count = 0)

Write column data.

Parameters
  • col – The index of the column to write.

  • vals – A std::vector with the data to write.

  • offset – Where to start.

  • count – How many columns to write.

template<typename T>
inline void readColumn(const std::string &name, std::vector<T> &vals, bool resize = false, ndsize_t offset = 0)

Read column data.

Parameters
  • name – Name of the column to read.

  • vals – A std::vector to store the data in

  • resize – Resize the vector to fit the data; if false the size of the vector is used as indication how much data to read.

  • offset – Where to start.

template<typename T>
inline void readColumn(unsigned col, std::vector<T> &vals, bool resize = false, ndsize_t offset = 0)

Read column data.

Parameters
  • col – Index of the column to read from.

  • vals – A std::vector to store the data in

  • resize – Resize the vector to fit the data; if false the size of the vector is used as indication how much data to read.

  • offset – Where to start.

template<typename T>
inline void readColumn(const std::string &name, std::vector<T> &vals, size_t count, bool resize, ndsize_t offset = 0)

Read column data.

Parameters
  • name – Name of the column to read.

  • vals – A std::vector to store the data in

  • count – How many rows to read.

  • resize – Resize the vector to fit the data

  • offset – Which row to start reading.

template<typename T>
inline void readColumn(unsigned col, std::vector<T> &vals, size_t count, bool resize, ndsize_t offset = 0)

Read column data.

Parameters
  • col – Index of the column to read data from.

  • vals – A std::vector to store the data in

  • count – How many rows to read.

  • resize – Resize the vector to fit the data

  • offset – Which row to start reading.