neurobooth_terra.redcap.dataframe_to_tuple

neurobooth_terra.redcap.dataframe_to_tuple(df, df_columns, fixed_columns=None, indicator_columns=None)[source]

Extract pandas dataframe into tuples for ingestion in Postgres.

Parameters
dfinstance of pd.Dataframe

The dataframe whose index is record_id

df_columnslist of str

The column names of the dataframe to process. The column_name ‘record_id’ is special and inserts the record_id index.

fixed_columnsdict | None

The columns that have fixed values. E.g., dict(study_id=study1) makes all the rows of column study_id to have value study1

indicator_columnslist of str | None

The indicator columns.

Returns
rowslist (n_rows,) of tuples

A list with each row having the columns of dataframe.

colslist of str

Ordered list of columns in which the tuple entries are added