hypertools.tools.df2mat

hypertools.tools.df2mat(data, return_labels=False)[source]

Transforms a Pandas DataFrame into a Numpy array with binarized text columns

This function transforms single-level df to an array so it can be plotted with HyperTools. Additionally, it uses the Pandas.Dataframe.get_dummies function to transform text columns into binary vectors, or ‘dummy variables’.

Parameters
dataA single-level Pandas DataFrame

The df that you want to convert. Note that this currently only works with single-level (not Multi-level indices).

Returns
plot_dataNumpy array

A Numpy array where text columns are turned into binary vectors.

labelslist (optional)

A list of column labels for the numpy array. To return this, set return_labels=True.