Skip to content

Commit 94bc76d

Browse files
committed
fix bug where empty first element leads to error
1 parent a365496 commit 94bc76d

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

mne/io/eyelink/_utils.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -559,10 +559,20 @@ def _drop_status_col(samples_df):
559559
status_cols = []
560560
# we know the first 3 columns will be the time, xpos, ypos
561561
for col in samples_df.columns[3:]:
562-
if samples_df[col][0][0].isnumeric():
563-
# if the value is numeric, it's not a status column
562+
first_valid_index = samples_df[col].first_valid_index()
563+
if first_valid_index is None:
564+
# The entire column is NaN, so we can drop it
565+
status_cols.append(col)
564566
continue
565-
if len(samples_df[col][0]) in [3, 5, 13, 17]:
567+
value = samples_df.loc[first_valid_index, col]
568+
try:
569+
float(value)
570+
continue # if the value is numeric, it's not a status column
571+
except (ValueError, TypeError):
572+
# cannot convert to float, so it might be a status column
573+
pass
574+
# further check the length of the string value
575+
if len(value) in [3, 5, 13, 17]:
566576
status_cols.append(col)
567577
return samples_df.drop(columns=status_cols)
568578

0 commit comments

Comments
 (0)