| 3743 | |
| 3744 | @pytest.mark.parametrize("func", ["idxmin", "idxmax"]) |
| 3745 | def test_idxmaxmin_numeric_only(func): |
| 3746 | df = pd.DataFrame( |
| 3747 | { |
| 3748 | "int": [1, 2, 3, 4, 5, 6, 7, 8], |
| 3749 | "float": [1.0, 2.0, 3.0, 4.0, np.nan, 6.0, 7.0, 8.0], |
| 3750 | "dt": [pd.NaT] + [datetime(2010, i, 1) for i in range(1, 8)], |
| 3751 | "timedelta": pd.to_timedelta([1, 2, 3, 4, 5, 6, 7, np.nan]), |
| 3752 | "bool": [True, False] * 4, |
| 3753 | } |
| 3754 | ) |
| 3755 | ddf = dd.from_pandas(df, npartitions=2) |
| 3756 | assert_eq( |
| 3757 | getattr(ddf, func)(numeric_only=False), |
| 3758 | getattr(df, func)(numeric_only=False).sort_index(), |
| 3759 | ) |
| 3760 | assert_eq( |
| 3761 | getattr(ddf, func)(numeric_only=True), |
| 3762 | getattr(df, func)(numeric_only=True).sort_index(), |
| 3763 | ) |
| 3764 | |
| 3765 | assert_eq( |
| 3766 | getattr(ddf.drop(columns="bool"), func)(numeric_only=True, axis=1), |
| 3767 | getattr(df.drop(columns="bool"), func)(numeric_only=True, axis=1).sort_index(), |
| 3768 | ) |
| 3769 | |
| 3770 | |
| 3771 | def test_idxmaxmin_empty_partitions(): |