liwca.merge_dx

On this page

liwca.merge_dx#

liwca.merge_dx(*dxs)[source]#

Merge multiple dictionaries into a single dictionary.

If any input is weighted (float64 columns), all inputs are promoted to float64 and the result is validated against dx_weighted_schema. Otherwise the result is binary (int8) and validated against dx_schema.

Parameters:

*dxs (pandas.DataFrame) – Two or more dictionary DataFrames to merge.

Returns:

The merged dictionary, validated against the appropriate schema (binary if all inputs are binary, weighted if any is weighted).

Return type:

pandas.DataFrame

Raises:

ValueError – If fewer than two dictionaries are provided, or if any dictionaries share category names (columns).

Examples

>>> import liwca
>>> dx_sleep = liwca.fetch_sleep()
>>> dx_threat = liwca.fetch_threat()
>>> merged = liwca.merge_dx(dx_sleep, dx_threat)
>>> merged.tail(3)
Category   sleep  threat
DicTerm
worse          0       1
worst          0       1
you awake      1       0