gwpopulation_pipe.common_format.data_frame_to_sarray

data_frame_to_sarray(data_frame)[source]

Convert a pandas DataFrame object to a numpy structured array. This is functionally equivalent to but more efficient than np.array(df.to_array()).

lifted from https://stackoverflow.com/questions/30773073/save-pandas-dataframe-using-h5py-for-interoperabilty-with-other-hdf5-readers

Parameters:
data_frame: pd.DataFrame

the data frame to convert

Returns:
output: np.ndarray

a numpy structured array representation of df