funpack.merging

This module contains functions which can merge data from multiple input files.

mergeDataFrames

Merges one or more pandas.DataFrames according to the given axis and strategy.

funpack.merging.mergeDataFrames(data, cols, axis, strategy, dryrun=False)[source]

Merges one or more pandas.DataFrames according to the given axis and strategy.

Parameters:
  • data – List of DataFrame objects to merge.

  • cols – List of lists - Column objects representing the columns in each data set in data.

  • axis – Axis to merge on - either subjects or variables.

  • strategy – Strategy to use for merging data, either union (an outer join), intersection (inner join), or naive (naive concatenation along axis).

  • dryrun – If True, only cols is merged.

Returns:

A tuple containing:

  • a new DataFrame containing the merged data, or None if dryrun is True.

  • A list of Column objects representing the columns that were kept. The index column is at the beginning of the list.

Warning

A dry run may produce different results with the naive merge strategy.