data_frame_operations#
- collapse_structures(df: DataFrame, map_collapse, collapse_hemispheres=False) DataFrame [source]#
collapses structures according to a dict map_collapse (id -> new_id) ids not in map_collapse are kept
- count_cells(path: str) DataFrame [source]#
counts cells from one file of type cells.feather returns df with columns id, hemisphere, cell_count and one row per structure x hemisphere
- filter_df(df: DataFrame, structure_ids, hemispheres=['RH', 'LH'], exclude: bool = False) DataFrame [source]#
returns a df that includes only the
- group_counts(counts_s, sample_names) DataFrame [source]#
groups several cell_counts together; sample_names are the names of the samples returns df with columns id, hemisphere, and one column per sample
- normalise_df_column_names(df)[source]#
Return same names wether df is a cell stats df or a group stats df :param df:
Returns
- sanitize_df(df, id_col_name='Structure ID')[source]#
Remove the rows corresponding to the “brain” structure and the rows with invalid ids
- Parameters:
df (pd.DataFrame) – The dataframe to sanitize
id_col_name (str) – The name of the column containing the ids
Returns
- pd.DataFrame
The sanitized dataframe