Skip to content

Commit 0204c7c

Browse files
committed
fix tests for pandas>=3
1 parent 572f4bf commit 0204c7c

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

tests/test_dfops.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def swap(x, y):
160160
def test_forward_fill_lazy_sparse_nans() -> None:
161161
"""test that a lazy forward fill works as expected with sparse nans"""
162162
t_df = df.copy()
163-
t_df["energy"][::2] = np.nan
163+
t_df.iloc[::2, 2] = np.nan
164164
t_dask_df = ddf.from_pandas(t_df, npartitions=N_PARTITIONS)
165165
t_dask_df = forward_fill_lazy(t_dask_df, "energy", before="max")
166166
t_df = t_df.ffill()
@@ -170,7 +170,7 @@ def test_forward_fill_lazy_sparse_nans() -> None:
170170
def test_forward_fill_lazy_full_partition_nans() -> None:
171171
"""test that a lazy forward fill works as expected with a full partition of nans"""
172172
t_df = df.copy()
173-
t_df["energy"][5:25] = np.nan
173+
t_df.iloc[5:25, 2] = np.nan
174174
t_dask_df = ddf.from_pandas(t_df, npartitions=N_PARTITIONS)
175175
t_dask_df = forward_fill_lazy(t_dask_df, "energy", before="max")
176176
t_df = t_df.ffill()
@@ -182,7 +182,7 @@ def test_forward_fill_lazy_consecutive_full_partition_nans() -> None:
182182
full of nans
183183
"""
184184
t_df = df.copy()
185-
t_df["energy"][5:35] = np.nan
185+
t_df.iloc[5:35, 2] = np.nan
186186
t_dask_df = ddf.from_pandas(t_df, npartitions=N_PARTITIONS)
187187
t_dask_df = forward_fill_lazy(t_dask_df, "energy", before="max")
188188
t_df = t_df.ffill()
@@ -192,7 +192,7 @@ def test_forward_fill_lazy_consecutive_full_partition_nans() -> None:
192192
def test_forward_fill_lazy_wrong_parameters() -> None:
193193
"""test that a lazy forward fill fails as expected on wrong parameters"""
194194
t_df = df.copy()
195-
t_df["energy"][5:35] = np.nan
195+
t_df.iloc[5:35, 2] = np.nan
196196
t_dask_df = ddf.from_pandas(t_df, npartitions=N_PARTITIONS)
197197
with pytest.raises(TypeError):
198198
t_dask_df = forward_fill_lazy(t_dask_df, "energy", before="wrong parameter")
@@ -201,7 +201,7 @@ def test_forward_fill_lazy_wrong_parameters() -> None:
201201
def test_forward_fill_lazy_compute() -> None:
202202
"""test that a lazy forward fill works as expected with compute=True"""
203203
t_df = df.copy()
204-
t_df["energy"][5:35] = np.nan
204+
t_df.iloc[5:35, 2] = np.nan
205205
t_dask_df = ddf.from_pandas(t_df, npartitions=N_PARTITIONS)
206206
t_dask_df_comp = forward_fill_lazy(t_dask_df, "energy", before="max", compute_lengths=True)
207207
t_dask_df_nocomp = forward_fill_lazy(t_dask_df, "energy", before="max", compute_lengths=False)
@@ -212,7 +212,7 @@ def test_forward_fill_lazy_keep_head_nans() -> None:
212212
"""test that a lazy forward fill works as expected with missing values at the
213213
beginning of the dataframe"""
214214
t_df = df.copy()
215-
t_df["energy"][:5] = np.nan
215+
t_df.iloc[:5, 2] = np.nan
216216
t_dask_df = ddf.from_pandas(t_df, npartitions=N_PARTITIONS)
217217
t_df = forward_fill_lazy(t_dask_df, "energy", before="max").compute()
218218
assert np.all(np.isnan(t_df["energy"][:5]))
@@ -238,7 +238,7 @@ def test_forward_fill_lazy_wrong_channels() -> None:
238238
def test_forward_fill_lazy_multiple_iterations() -> None:
239239
"""test that a lazy forward fill works as expected with multiple iterations"""
240240
t_df = df.copy()
241-
t_df["energy"][5:35] = np.nan
241+
t_df.loc[5:35, "energy"] = np.nan
242242
t_dask_df = ddf.from_pandas(t_df, npartitions=N_PARTITIONS)
243243
t_dask_df = forward_fill_lazy(t_dask_df, "energy", before="max", iterations=5)
244244
t_df = t_df.ffill()

0 commit comments

Comments
 (0)