Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Change the shape of the output DataFrame of `extract_dataframe` (#862)

Choose a tag to compare

@wizmer wizmer released this 11 Jan 14:03
e994920
💥 Change the shape of the output DataFrame of `extract_dataframe` (#862)

`extract_dataframe` used to return `N` rows for each neuron where `N` is the
number of neurite types in the input config.

## Context

Since `extract_dataframe` input is a list of neuron, it is more natural to
return exactly one row per neuron.

## Proposed change

Use a MultiIndex on the columns to hold the metrics for each neurite type
instead of having the neurite type appear in the index (axis=0).

## Example: 

Before:

|   | name    | neurite_type    | metric A | metric B |
|---|---------|-----------------|----------|----------|
| 0 | no-axon | axon            | val A    | val B    |
| 1 | no-axon | apical_dendrite | val A'   | val B'   |

After:


|   |         | axon                | apical_dendrite            |
|   | name    | metric A | metric B | metric A        | metric B |
|---|---------|----------|----------|-----------------|----------|
| 0 | no-axon | val A    | val B    | val A'          | val B'   |

## :sparkles: Additional modification

The returned dataframe is now sorted as the input list of neuron and support multiple neuron with the same name

In practice

- `imap` is now used instead of `imap_unordered`. Maintaining the sorting is worth the slight performance decrease.
-  the intermediate results are no longer stored in a `dict` but in a `list`. This enables having multiple neuron with the same name. This is for example useful to compare releases.