nimare.utils.add_metadata_to_dataframe
- add_metadata_to_dataframe(dataset, dataframe, metadata_field, target_column, filter_func=<function mean>)[source]
Add metadata from a Dataset to a DataFrame.
New in version 0.0.8.
This is particularly useful for kernel transformers or estimators where a given metadata field is necessary (e.g., ALEKernel with “sample_size”), but we want to just use the coordinates DataFrame instead of passing the full Dataset.
- Parameters
dataset (
nimare.dataset.Dataset) – Dataset containing study IDs and metadata to feed into dataframe.dataframe (
pandas.DataFrame) – DataFrame containing study IDs, into which Dataset metadata will be merged.metadata_field (
str) – Metadata field indataset.target_column (
str) – Name of the column that will be added todataframe, containing information from the Dataset.filter_func (
function, optional) – Function to apply to the metadata so that it fits as a column in a DataFrame. Default isnumpy.mean.
- Returns
dataframe (
pandas.DataFrame) – Updated DataFrame withtarget_columnadded.