MCPcopy Create free account
hub / github.com/dask/dask / test_dropna

Function test_dropna

dask/dataframe/tests/test_dataframe.py:682–721  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

680
681
682def test_dropna():
683 df = pd.DataFrame(
684 {
685 "x": [np.nan, 2, 3, 4, np.nan, 6],
686 "y": [1, 2, np.nan, 4, np.nan, np.nan],
687 "z": [1, 2, 3, 4, np.nan, 6],
688 },
689 index=[10, 20, 30, 40, 50, 60],
690 )
691 ddf = dd.from_pandas(df, 3)
692
693 assert_eq(ddf.x.dropna(), df.x.dropna())
694 assert_eq(ddf.y.dropna(), df.y.dropna())
695 assert_eq(ddf.z.dropna(), df.z.dropna())
696
697 assert_eq(ddf.dropna(), df.dropna())
698 assert_eq(ddf.dropna(how="all"), df.dropna(how="all"))
699 assert_eq(ddf.dropna(subset=["x"]), df.dropna(subset=["x"]))
700 assert_eq(ddf.dropna(subset=["y", "z"]), df.dropna(subset=["y", "z"]))
701 assert_eq(
702 ddf.dropna(subset=["y", "z"], how="all"),
703 df.dropna(subset=["y", "z"], how="all"),
704 )
705
706 # threshold
707 assert_eq(ddf.dropna(thresh=None), df.dropna(thresh=None))
708 assert_eq(ddf.dropna(thresh=0), df.dropna(thresh=0))
709 assert_eq(ddf.dropna(thresh=1), df.dropna(thresh=1))
710 assert_eq(ddf.dropna(thresh=2), df.dropna(thresh=2))
711 assert_eq(ddf.dropna(thresh=3), df.dropna(thresh=3))
712
713 # fail when how and thresh are both provided
714 # see https://github.com/dask/dask/issues/9365
715 with pytest.raises(TypeError, match="cannot set both the how and thresh arguments"):
716 ddf.dropna(how="all", thresh=0)
717
718 # Regression test for https://github.com/dask/dask/issues/6540
719 df = pd.DataFrame({"_0": [0, 0, np.nan], "_1": [1, 2, 3]})
720 ddf = dd.from_pandas(df, npartitions=2)
721 assert_eq(ddf.dropna(subset=["_0"]), df.dropna(subset=["_0"]))
722
723
724@pytest.mark.parametrize("lower, upper", [(2, 5), (2.5, 3.5)])

Callers

nothing calls this directly

Calls 3

dropnaMethod · 0.95
assert_eqFunction · 0.90
dropnaMethod · 0.45

Tested by

no test coverage detected