Inviwo 0.9.12-pre
Inviwo documentation
Loading...
Searching...
No Matches
inviwo::dataframe Namespace Reference

Functions

IVW_MODULE_DATAFRAME_API std::shared_ptr< BufferBasecloneBufferRange (std::shared_ptr< const BufferBase > buffer, ivec2 range)
 
IVW_MODULE_DATAFRAME_API void copyBufferRange (std::shared_ptr< const BufferBase > src, std::shared_ptr< BufferBase > dst, ivec2 range, size_t dstStart=0)
 
IVW_MODULE_DATAFRAME_API std::shared_ptr< DataFrameappendColumns (const DataFrame &left, const DataFrame &right, bool ignoreDuplicates=false, bool fillMissingRows=false)
 create a new DataFrame by appending the columns of DataFrame right to DataFrame left
 
IVW_MODULE_DATAFRAME_API std::shared_ptr< DataFrameappendRows (const DataFrame &top, const DataFrame &bottom, bool matchByName=false)
 create a new DataFrame by appending the rows of DataFrame bottom to DataFrame top
 
IVW_MODULE_DATAFRAME_API std::shared_ptr< DataFrameinnerJoin (const DataFrame &left, const DataFrame &right, const std::pair< std::string, std::string > &keyColumns={"index", "index"})
 create a new DataFrame by using an inner join of DataFrame left and DataFrame right. That is only rows with matching keys are kept. The row indices of left will be reused.
 
IVW_MODULE_DATAFRAME_API std::shared_ptr< DataFrameinnerJoin (const DataFrame &left, const DataFrame &right, const std::vector< std::pair< std::string, std::string > > &keyColumns)
 create a new DataFrame by using an inner join of DataFrame left and DataFrame right. That is only rows with matching keys are kept. The row indices of left will be reused.
 
IVW_MODULE_DATAFRAME_API std::shared_ptr< DataFrameleftJoin (const DataFrame &left, const DataFrame &right, const std::pair< std::string, std::string > &keyColumns={"index", "index"})
 create a new DataFrame by using an outer left join of DataFrame left and DataFrame right. That is all rows of left are augmented with matching rows from right. The row indices of left will be reused.
 
IVW_MODULE_DATAFRAME_API std::shared_ptr< DataFrameleftJoin (const DataFrame &left, const DataFrame &right, const std::vector< std::pair< std::string, std::string > > &keyColumns)
 create a new DataFrame by using an outer left join of DataFrame left and DataFrame right. That is all rows of left are augmented with matching rows from right. The row indices of left will be reused.
 
IVW_MODULE_DATAFRAME_API std::shared_ptr< DataFramecombineDataFrames (std::vector< std::shared_ptr< DataFrame > > dataframes, bool skipIndexColumn=false, std::string skipcol="index")
 
template<typename Pred >
std::vector< std::uint32_t > selectRows (std::shared_ptr< const Column > col, Pred pred)
 apply predicate pred to each value of column col and return the row indices where the predicate evaluates to true.
 
IVW_MODULE_DATAFRAME_API std::vector< std::uint32_t > selectRows (const Column &col, const std::vector< dataframefilters::ItemFilter > &filters)
 apply the filters to each row of column col and return the row indices where any of the filters evaluates to true.
 
IVW_MODULE_DATAFRAME_API std::vector< std::uint32_t > selectRows (const DataFrame &dataframe, dataframefilters::Filters filters)
 apply the filters to each row of dataframe and return the row indices where any of the include filters and no exclude filter evaluates to true.
 
IVW_MODULE_DATAFRAME_API std::string createToolTipForRow (const DataFrame &dataframe, size_t rowId)
 

Detailed Description

Utility functions for DataFrame operations

Function Documentation

◆ appendColumns()

IVW_MODULE_DATAFRAME_API std::shared_ptr< DataFrame > inviwo::dataframe::appendColumns ( const DataFrame & left,
const DataFrame & right,
bool ignoreDuplicates = false,
bool fillMissingRows = false )

create a new DataFrame by appending the columns of DataFrame right to DataFrame left

Parameters
left
right
ignoreDuplicatesduplicate columns, i.e. same column header, are ignored if true
fillMissingRowsif true, missing rows in either DataFrame are filled with 0 or "undefined" (for categorical columns)
Returns
joined DataFrame with columns from left and right DataFrame
Exceptions
Exceptionif number of rows is different and fillMissingRows is false

◆ appendRows()

IVW_MODULE_DATAFRAME_API std::shared_ptr< DataFrame > inviwo::dataframe::appendRows ( const DataFrame & top,
const DataFrame & bottom,
bool matchByName = false )

create a new DataFrame by appending the rows of DataFrame bottom to DataFrame top

Parameters
top
bottom
matchByNameif true, column headers are used for matching columns. Otherwise columns are matched by order (default)
Returns
joined DataFrame with columns from left and right DataFrame
Exceptions
Exceptionif number of columns is different or a column cannot be found (matchByName)

◆ innerJoin() [1/2]

IVW_MODULE_DATAFRAME_API std::shared_ptr< DataFrame > inviwo::dataframe::innerJoin ( const DataFrame & left,
const DataFrame & right,
const std::pair< std::string, std::string > & keyColumns = {"index", "index"} )

create a new DataFrame by using an inner join of DataFrame left and DataFrame right. That is only rows with matching keys are kept. The row indices of left will be reused.

It is assumed that the entries in the key columns are unique. Otherwise results are undefined.

Parameters
left
right
keyColumnsheaders of the columns used as keys for the join operation (default: index and index column)
Returns
inner join of left and right DataFrame
Exceptions
Exceptionif keyColumn does not exist in either left or right

◆ innerJoin() [2/2]

IVW_MODULE_DATAFRAME_API std::shared_ptr< DataFrame > inviwo::dataframe::innerJoin ( const DataFrame & left,
const DataFrame & right,
const std::vector< std::pair< std::string, std::string > > & keyColumns )

create a new DataFrame by using an inner join of DataFrame left and DataFrame right. That is only rows with matching keys are kept. The row indices of left will be reused.

It is assumed that the entries in the key columns are unique. Otherwise results are undefined.

Parameters
left
right
keyColumnsheaders of the columns used as keys for the join operation
Returns
inner join of left and right DataFrame
Exceptions
Exceptionif keyColumn does not exist in either left or right

◆ leftJoin() [1/2]

IVW_MODULE_DATAFRAME_API std::shared_ptr< DataFrame > inviwo::dataframe::leftJoin ( const DataFrame & left,
const DataFrame & right,
const std::pair< std::string, std::string > & keyColumns = {"index", "index"} )

create a new DataFrame by using an outer left join of DataFrame left and DataFrame right. That is all rows of left are augmented with matching rows from right. The row indices of left will be reused.

It is assumed that the entries in the key columns of right are unique. Otherwise results are undefined.

Parameters
left
right
keyColumnsheaders of the columns used as keys for the join operation (default: index and index column)
Returns
left join of left and right DataFrame
Exceptions
Exceptionif keyColumn does not exist in either left or right

◆ leftJoin() [2/2]

IVW_MODULE_DATAFRAME_API std::shared_ptr< DataFrame > inviwo::dataframe::leftJoin ( const DataFrame & left,
const DataFrame & right,
const std::vector< std::pair< std::string, std::string > > & keyColumns )

create a new DataFrame by using an outer left join of DataFrame left and DataFrame right. That is all rows of left are augmented with matching rows from right. The row indices of left will be reused.

It is assumed that the entries in the key columns of right are unique. Otherwise results are undefined.

Parameters
left
right
keyColumnsheaders of the columns used as keys for the join operation
Returns
left join of left and right DataFrame
Exceptions
Exceptionif keyColumn does not exist in either left or right

◆ selectRows() [1/3]

IVW_MODULE_DATAFRAME_API std::vector< std::uint32_t > inviwo::dataframe::selectRows ( const Column & col,
const std::vector< dataframefilters::ItemFilter > & filters )

apply the filters to each row of column col and return the row indices where any of the filters evaluates to true.

Parameters
colcolumn containing data for filtering
filterspredicate to check values from col
Returns
list of row indices where rows satisfy all filters
See also
selectRows(const DataFrame&, dataframefilters::Filters)

◆ selectRows() [2/3]

IVW_MODULE_DATAFRAME_API std::vector< std::uint32_t > inviwo::dataframe::selectRows ( const DataFrame & dataframe,
dataframefilters::Filters filters )

apply the filters to each row of dataframe and return the row indices where any of the include filters and no exclude filter evaluates to true.

Parameters
dataframecolumn containing data for filtering
filterspredicate to check values from col
Returns
list of row indices where rows satisfy all filters
See also
selectRows(const Column&, dataframefilters::Filters)

◆ selectRows() [3/3]

template<typename Pred >
std::vector< std::uint32_t > inviwo::dataframe::selectRows ( std::shared_ptr< const Column > col,
Pred pred )

apply predicate pred to each value of column col and return the row indices where the predicate evaluates to true.

Note: the predicate function needs to take care of the different column datatypes

auto pred = [](const auto& arg) {
if constexpr(std::is_same_v<decltype(arg), float>) {
return arg == 4.5f
} else {
return true;
}};

Alternatively, predicate overloads can be used.

#include <inviwo/core/util/stdextensions.h>
auto pred = util::overloaded{[](const std::string& arg) { return arg == "bla"; },
[](const int& arg) { return arg == 5; },
[](const auto&) { return true; });
Definition stdextensions.h:121
Parameters
colcolumn containing data for filtering
predpredicate to check values from col
Returns
list of row indices where rows fulfill the predicate
See also
selectRows(const DataFrame&, dataframefilters::Filters)