def test_iLocIndexer_class_error(sample_df_dask, sample_series_dask): with pytest.raises(TypeError, match="iloc is not supported for Dask DataFrames"): _iLocIndexer(sample_df_dask) with pytest.raises(TypeError, match="iloc is not supported for Dask Series"): _iLocIndexer(sample_series_dask)
def test_iLocIndexer_class_error(sample_df_dask, sample_series_dask): dt_dask = ww.DataTable(sample_df_dask) with pytest.raises(TypeError, match="iloc is not supported for Dask DataTables"): _iLocIndexer(dt_dask) dc_dask = ww.DataColumn(sample_series_dask) with pytest.raises(TypeError, match="iloc is not supported for Dask DataColumns"): _iLocIndexer(dc_dask)
def test_iLocIndexer_class(sample_df): if dd and isinstance(sample_df, dd.DataFrame): pytest.xfail('iloc is not supported with Dask inputs') sample_df.ww.init() ind = _iLocIndexer(sample_df) pd.testing.assert_frame_equal(to_pandas(ind.data), to_pandas(sample_df)) pd.testing.assert_frame_equal(to_pandas(ind[1:2]), to_pandas(sample_df.iloc[1:2])) assert ind[0, 0] == 0
def test_iLocIndexer_class(sample_df): if _is_dask_dataframe(sample_df): pytest.xfail("iloc is not supported with Dask inputs") sample_df.ww.init() ind = _iLocIndexer(sample_df) pd.testing.assert_frame_equal(to_pandas(ind.data), to_pandas(sample_df)) pd.testing.assert_frame_equal(to_pandas(ind[1:2]), to_pandas(sample_df.iloc[1:2])) assert ind[0, 0] == 0
def test_iLocIndexer_class(sample_df): if dd and isinstance(sample_df, dd.DataFrame): pytest.xfail('iloc is not supported with Dask inputs') dt = ww.DataTable(sample_df) ind = _iLocIndexer(dt) pd.testing.assert_frame_equal(to_pandas(ind.underlying_data), to_pandas(sample_df)) pd.testing.assert_frame_equal(to_pandas(ind[1:2].to_dataframe()), to_pandas(sample_df.iloc[1:2])) assert ind[0, 0] == 0
def iloc(self): """Purely integer-location based indexing for selection by position. ``.iloc[]`` is primarily integer position based (from ``0`` to ``length-1`` of the axis), but may also be used with a boolean array. Allowed inputs are: An integer, e.g. ``5``. A list or array of integers, e.g. ``[4, 3, 0]``. A slice object with ints, e.g. ``1:7``. A boolean array. A ``callable`` function with one argument (the calling Series, DataFrame or Panel) and that returns valid output for indexing (one of the above). This is useful in method chains, when you don't have a reference to the calling object, but would like to base your selection on some value. """ return _iLocIndexer(self)
def iloc(self): """ Integer-location based indexing for selection by position. ``.iloc[]`` is primarily integer position based (from ``0`` to ``length-1`` of the axis), but may also be used with a boolean array. If the selection result is a DataFrame or Series, Woodwork typing information will be initialized for the returned object when possible. Allowed inputs are: An integer, e.g. ``5``. A list or array of integers, e.g. ``[4, 3, 0]``. A slice object with ints, e.g. ``1:7``. A boolean array. A ``callable`` function with one argument (the calling Series, DataFrame or Panel) and that returns valid output for indexing (one of the above). This is useful in method chains, when you don't have a reference to the calling object, but would like to base your selection on some value. """ if self._schema is None: _raise_init_error() return _iLocIndexer(self._dataframe)