Skip to content

Commit 31f0441

Browse files
committed
fix: Suppress inapplicable pandas FutureWarning
1 parent 77c644b commit 31f0441

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

bids/variables/collections.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,14 @@ def to_df(
158158
ent_cols = list(all_cols - {"condition", "amplitude", "onset", "duration"})
159159

160160
if format == "long":
161-
df = df.reset_index(drop=True).fillna(fillna)
161+
with warnings.catch_warnings():
162+
# This change in behavior doesn't affect our usage, so ignore warnings
163+
# without setting a global config for Pandas.
164+
# Short story: fillna used to downcast object to float64, but if it isn't
165+
# already float64, we have non-float objects in the column, so we've never
166+
# downcasted.
167+
warnings.filterwarnings("ignore", message='no_silent_downcasting', category=FutureWarning)
168+
df = df.reset_index(drop=True).fillna(fillna)
162169
else:
163170
# Rows in wide format can only be defined by combinations of level entities
164171
# plus (for run-level variables) onset and duration.

0 commit comments

Comments
 (0)