Skip to content

Commit

Permalink
Merge pull request #3622 from samuelgarcia/fix_dataframe_index_dtype
Browse files Browse the repository at this point in the history
Fix dataframe index dtype due to csv in  quality metrics
  • Loading branch information
alejoe91 authored Jan 15, 2025
2 parents 01d1479 + e3b2f16 commit 7ae08cc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/spikeinterface/core/sortinganalyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2092,6 +2092,13 @@ def load_data(self):
import pandas as pd

ext_data = pd.read_csv(ext_data_file, index_col=0)
# we need to cast the index to the unit id dtype (int or str)
unit_ids = self.sorting_analyzer.unit_ids
if ext_data.shape[0] == unit_ids.size:
# we force dtype to be the same as unit_ids
if ext_data.index.dtype != unit_ids.dtype:
ext_data.index = ext_data.index.astype(unit_ids.dtype)

elif ext_data_file.suffix == ".pkl":
with ext_data_file.open("rb") as f:
ext_data = pickle.load(f)
Expand Down

0 comments on commit 7ae08cc

Please sign in to comment.