From 8d16271e53c25e742094de5558d2937e02549ee3 Mon Sep 17 00:00:00 2001 From: Jeff Reback Date: Sat, 14 Oct 2017 14:50:47 -0400 Subject: [PATCH] TST: remove some deprecation warnings (#17870) --- pandas/io/html.py | 5 ++++- pandas/tests/indexes/test_multi.py | 2 +- pandas/tests/plotting/test_frame.py | 2 +- pandas/tests/plotting/test_misc.py | 1 - pandas/tests/reshape/test_merge.py | 12 ++++++------ pandas/tests/test_categorical.py | 6 +++--- pandas/tests/test_panel.py | 12 ++++++------ pandas/tests/test_panel4d.py | 4 ++-- 8 files changed, 23 insertions(+), 21 deletions(-) diff --git a/pandas/io/html.py b/pandas/io/html.py index b5aaffcf710c2..6f98683a1bff1 100644 --- a/pandas/io/html.py +++ b/pandas/io/html.py @@ -759,7 +759,7 @@ def _parse(flavor, io, match, attrs, encoding, **kwargs): def read_html(io, match='.+', flavor=None, header=None, index_col=None, skiprows=None, attrs=None, parse_dates=False, - tupleize_cols=False, thousands=',', encoding=None, + tupleize_cols=None, thousands=',', encoding=None, decimal='.', converters=None, na_values=None, keep_default_na=True): r"""Read HTML tables into a ``list`` of ``DataFrame`` objects. @@ -828,6 +828,9 @@ def read_html(io, match='.+', flavor=None, header=None, index_col=None, :class:`~pandas.MultiIndex`, otherwise return raw tuples. Defaults to ``False``. + .. deprecated:: 0.21.0 + This argument will be removed and will always convert to MultiIndex + thousands : str, optional Separator to use to parse thousands. Defaults to ``','``. diff --git a/pandas/tests/indexes/test_multi.py b/pandas/tests/indexes/test_multi.py index b1b5413b4d081..18bfc3d0efbee 100644 --- a/pandas/tests/indexes/test_multi.py +++ b/pandas/tests/indexes/test_multi.py @@ -458,7 +458,7 @@ def test_set_value_keeps_names(self): df = df.sort_index() assert df.is_copy is None assert df.index.names == ('Name', 'Number') - df = df.set_value(('grethe', '4'), 'one', 99.34) + df.at[('grethe', '4'), 'one'] = 99.34 assert df.is_copy is None assert df.index.names == ('Name', 'Number') diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py index a428d73fce1e3..11dca1abc5ec7 100644 --- a/pandas/tests/plotting/test_frame.py +++ b/pandas/tests/plotting/test_frame.py @@ -2835,7 +2835,7 @@ def test_plain_axes(self): Series(rand(10)).plot(ax=cax) fig, ax = self.plt.subplots() - from mpl_toolkits.axes_grid.inset_locator import inset_axes + from mpl_toolkits.axes_grid1.inset_locator import inset_axes iax = inset_axes(ax, width="30%", height=1., loc=3) Series(rand(10)).plot(ax=ax) Series(rand(10)).plot(ax=iax) diff --git a/pandas/tests/plotting/test_misc.py b/pandas/tests/plotting/test_misc.py index 957369a20f16e..6f476553091d9 100644 --- a/pandas/tests/plotting/test_misc.py +++ b/pandas/tests/plotting/test_misc.py @@ -204,7 +204,6 @@ def test_parallel_coordinates(self): def test_parallel_coordinates_with_sorted_labels(self): """ For #15908 """ from pandas.plotting import parallel_coordinates - df = DataFrame({"feat": [i for i in range(30)], "class": [2 for _ in range(10)] + [3 for _ in range(10)] + diff --git a/pandas/tests/reshape/test_merge.py b/pandas/tests/reshape/test_merge.py index 81956c0bd5b28..172667c9a0fb8 100644 --- a/pandas/tests/reshape/test_merge.py +++ b/pandas/tests/reshape/test_merge.py @@ -1546,6 +1546,7 @@ def test_dtype_on_categorical_dates(self): result_inner = pd.merge(df, df2, how='inner', on=['date']) assert_frame_equal(result_inner, expected_inner) + @pytest.mark.parametrize('ordered', [True, False]) @pytest.mark.parametrize('category_column,categories,expected_categories', [([False, True, True, False], [True, False], [True, False]), @@ -1554,20 +1555,19 @@ def test_dtype_on_categorical_dates(self): ['True', 'False'], ['True', 'False'])]) def test_merging_with_bool_or_int_cateorical_column(self, category_column, categories, - expected_categories): + expected_categories, + ordered): # GH 17187 # merging with a boolean/int categorical column df1 = pd.DataFrame({'id': [1, 2, 3, 4], 'cat': category_column}) - df1['cat'] = df1['cat'].astype('category', - categories=categories, ordered=True) + df1['cat'] = df1['cat'].astype(CDT(categories, ordered=ordered)) df2 = pd.DataFrame({'id': [2, 4], 'num': [1, 9]}) result = df1.merge(df2) expected = pd.DataFrame({'id': [2, 4], 'cat': expected_categories, 'num': [1, 9]}) - expected['cat'] = expected['cat'].astype('category', - categories=categories, - ordered=True) + expected['cat'] = expected['cat'].astype( + CDT(categories, ordered=ordered)) assert_frame_equal(expected, result) diff --git a/pandas/tests/test_categorical.py b/pandas/tests/test_categorical.py index 64c89dbdd0aa4..e1d0b756fed1c 100644 --- a/pandas/tests/test_categorical.py +++ b/pandas/tests/test_categorical.py @@ -3592,7 +3592,7 @@ def test_slicing_and_getting_ops(self): tm.assert_frame_equal(res_fancy, exp_fancy) # get_value - res_val = df.get_value("j", "cats") + res_val = df.at["j", "cats"] assert res_val == exp_val # i : int, slice, or sequence of integers @@ -3956,12 +3956,12 @@ def f(): # set_value df = orig.copy() - df.set_value("j", "cats", "b") + df.at["j", "cats"] = "b" tm.assert_frame_equal(df, exp_single_cats_value) def f(): df = orig.copy() - df.set_value("j", "cats", "c") + df.at["j", "cats"] = "c" pytest.raises(ValueError, f) diff --git a/pandas/tests/test_panel.py b/pandas/tests/test_panel.py index da30c8c403d41..e845fcac33323 100644 --- a/pandas/tests/test_panel.py +++ b/pandas/tests/test_panel.py @@ -1451,14 +1451,14 @@ def test_reindex_axis_style(self): expected1 = Panel(panel.values).iloc[:, [0, 1]] expected2 = Panel(panel.values).iloc[:, :, [0, 1]] - result = panel.reindex([0, 1], axis=0) - assert_panel_equal(result, expected0) + result = panel.reindex([0, 1], axis=0) + assert_panel_equal(result, expected0) - result = panel.reindex([0, 1], axis=1) - assert_panel_equal(result, expected1) + result = panel.reindex([0, 1], axis=1) + assert_panel_equal(result, expected1) - result = panel.reindex([0, 1], axis=2) - assert_panel_equal(result, expected2) + result = panel.reindex([0, 1], axis=2) + assert_panel_equal(result, expected2) def test_reindex_multi(self): with catch_warnings(record=True): diff --git a/pandas/tests/test_panel4d.py b/pandas/tests/test_panel4d.py index 49859fd27d7bc..c0e8770dff8b8 100644 --- a/pandas/tests/test_panel4d.py +++ b/pandas/tests/test_panel4d.py @@ -563,8 +563,8 @@ def test_get_value(self): for item in self.panel4d.items: for mjr in self.panel4d.major_axis[::2]: for mnr in self.panel4d.minor_axis: - result = self.panel4d.get_value( - label, item, mjr, mnr) + result = self.panel4d.loc[ + label, item, mjr, mnr] expected = self.panel4d[label][item][mnr][mjr] assert_almost_equal(result, expected)