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

Function test_dropna

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

Source from the content-addressed store, hash-verified

698
699
700def test_dropna():
701 df = pd.DataFrame(
702 {
703 "x": [np.nan, 2, 3, 4, np.nan, 6],
704 "y": [1, 2, np.nan, 4, np.nan, np.nan],
705 "z": [1, 2, 3, 4, np.nan, 6],
706 },
707 index=[10, 20, 30, 40, 50, 60],
708 )
709 ddf = dd.from_pandas(df, 3)
710
711 assert_eq(ddf.x.dropna(), df.x.dropna())
712 assert_eq(ddf.y.dropna(), df.y.dropna())
713 assert_eq(ddf.z.dropna(), df.z.dropna())
714
715 assert_eq(ddf.dropna(), df.dropna())
716 assert_eq(ddf.dropna(how="all"), df.dropna(how="all"))
717 assert_eq(ddf.dropna(subset=["x"]), df.dropna(subset=["x"]))
718 assert_eq(ddf.dropna(subset=["y", "z"]), df.dropna(subset=["y", "z"]))
719 assert_eq(
720 ddf.dropna(subset=["y", "z"], how="all"),
721 df.dropna(subset=["y", "z"], how="all"),
722 )
723
724 # threshold
725 assert_eq(ddf.dropna(thresh=None), df.dropna(thresh=None))
726 assert_eq(ddf.dropna(thresh=0), df.dropna(thresh=0))
727 assert_eq(ddf.dropna(thresh=1), df.dropna(thresh=1))
728 assert_eq(ddf.dropna(thresh=2), df.dropna(thresh=2))
729 assert_eq(ddf.dropna(thresh=3), df.dropna(thresh=3))
730
731 # fail when how and thresh are both provided
732 # see https://github.com/dask/dask/issues/9365
733 with pytest.raises(TypeError, match="cannot set both the how and thresh arguments"):
734 ddf.dropna(how="all", thresh=0)
735
736 # Regression test for https://github.com/dask/dask/issues/6540
737 df = pd.DataFrame({"_0": [0, 0, np.nan], "_1": [1, 2, 3]})
738 ddf = dd.from_pandas(df, npartitions=2)
739 assert_eq(ddf.dropna(subset=["_0"]), df.dropna(subset=["_0"]))
740
741
742@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