From 86ee3d6a9a00ba2df5951dcfd07d445886bb966c Mon Sep 17 00:00:00 2001 From: Adam Amster Date: Wed, 8 Dec 2021 12:11:54 -0500 Subject: [PATCH] Fix weirdness in this implementation. np.empty is given a 1d array to instantiate but dtype contains multiple columns --- .../ecephys/stimulus_analysis/stimulus_analysis.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/allensdk/brain_observatory/ecephys/stimulus_analysis/stimulus_analysis.py b/allensdk/brain_observatory/ecephys/stimulus_analysis/stimulus_analysis.py index 0d1cfdb14..a7cda420f 100644 --- a/allensdk/brain_observatory/ecephys/stimulus_analysis/stimulus_analysis.py +++ b/allensdk/brain_observatory/ecephys/stimulus_analysis/stimulus_analysis.py @@ -436,13 +436,13 @@ def metrics(self): raise NotImplementedError() def empty_metrics_table(self): - # pandas can have issues interpreting type and makes the column 'object' type, this should enforce the - # correct data type for each column - empty_array = np.empty(self.unit_count, dtype=np.dtype(self.METRICS_COLUMNS)) - empty_array[:] = np.nan - - return pd.DataFrame(empty_array, index=self.unit_ids).rename_axis('unit_id') + empty_array = np.empty((self.unit_count, len(self.METRICS_COLUMNS))) + df = pd.DataFrame(empty_array, + index=pd.Index(self.unit_ids, name='unit_id'), + columns=[x[0] for x in self.METRICS_COLUMNS]) + df = df.astype(dict(self.METRICS_COLUMNS)) + return df def _find_stimuli(self): raise NotImplementedError()