long_df_to_wide_ndarray#

pandas_utils.df_handling.long_df_to_wide_ndarray(*args, **kwargs)#

Convert a DataFrame from long to wide format, infilling missing values.

Similar to the long_to_wide_infill() function, but returns a numpy array instead.

Parameters:
  • df – The dataframe, in long format, to convert to a wide numpy array.

  • index_col – The column of df to use as the index of the wide return DataFrame

  • columns_col – The column of df to use as the columns of the wide return DataFrame

  • values_col – The column of df to use as the values of the wide return DataFrame

  • index_vals – The unique values to use as the index of the wide return DataFrame. If left as None, df[index_col].unique() will be used.

  • column_vals – The unique values to use as the columns of the wide return DataFrame. If left as None, df[columns_col].unique() will be used.

  • infill – The value to use to infill any missing cells in the wide DataFrame.

  • check_totals – Whether to check if the totals are almost equal before and after the conversion.

Returns:

An ndarray, in wide format, with index_col as the index, columns_col as the column names, and values_col as the values.

Return type:

wide_ndarray