Skip to content

Commit 0d70d70

Browse files
committed
REF: Call the pandas DataFrame constructor with the same data
Call the pandas DataFrame constructor with the same data instead of copying. Fixes: ``` nireports/tests/test_reportlets.py::test_plot_raincloud[True-v] nireports/tests/test_reportlets.py::test_plot_raincloud[False-h] nireports/tests/test_reportlets.py::test_plot_raincloud[False-v] nireports/tests/test_reportlets.py::test_plot_raincloud[True-h] /home/runner/work/nireports/nireports/nireports/reportlets/nuisance.py:1108: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy df_clip[feature] = df[feature].clip(lower=lower_limit_value, upper=upper_limit_value) ``` raised for example in: https://github.com/nipreps/nireports/actions/runs/16604968354/job/46974298946?pr=157#step:14:476
1 parent 4bfabed commit 0d70d70

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

nireports/reportlets/nuisance.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,8 +1104,8 @@ def plot_raincloud(
11041104

11051105
df = pd.read_csv(data_file, sep=r"[\t\s]+", engine="python")
11061106

1107-
df_clip = df.copy(deep=True)
1108-
df_clip[feature] = df[feature].clip(lower=lower_limit_value, upper=upper_limit_value)
1107+
df_clip = pd.DataFrame(df, copy=True)
1108+
df_clip[feature] = df_clip[feature].clip(lower=lower_limit_value, upper=upper_limit_value)
11091109

11101110
figure = figure if figure is not None else plt.figure(figsize=(7, 5))
11111111
gs = GridSpec(1, 1)

0 commit comments

Comments
 (0)