diff --git a/pandas/core/reshape/reshape.py b/pandas/core/reshape/reshape.py index 7260bc9a8b7a1..bff09be6149f3 100644 --- a/pandas/core/reshape/reshape.py +++ b/pandas/core/reshape/reshape.py @@ -851,7 +851,7 @@ def lreshape(data, groups, dropna=True, label=None): return DataFrame(mdata, columns=id_cols + pivot_cols) -def wide_to_long(df, stubnames, i, j, sep="", suffix='\d+'): +def wide_to_long(df, stubnames, i, j, sep="", suffix=r'\d+'): r""" Wide panel to long format. Less flexible but more user-friendly than melt. diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 7a40018494fc4..aa919d600ec52 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -2726,7 +2726,7 @@ def barh(self, x=None, y=None, **kwds): return self(kind='barh', x=x, y=y, **kwds) def box(self, by=None, **kwds): - """ + r""" Boxplot .. versionadded:: 0.17.0 diff --git a/pandas/tests/frame/test_operators.py b/pandas/tests/frame/test_operators.py index 5052bef24e95a..309c0f0244d7c 100644 --- a/pandas/tests/frame/test_operators.py +++ b/pandas/tests/frame/test_operators.py @@ -1035,6 +1035,12 @@ def test_boolean_comparison(self): result = df == tup assert_frame_equal(result, expected) + def test_boolean_comparison_error(self): + + # GH 4576 + # boolean comparisons with a tuple/list give unexpected results + df = DataFrame(np.arange(6).reshape((3, 2))) + # not shape compatible pytest.raises(ValueError, lambda: df == (2, 2)) pytest.raises(ValueError, lambda: df == [2, 2]) diff --git a/pandas/tests/indexes/test_interval.py b/pandas/tests/indexes/test_interval.py index dc59495f619b0..b55bab3a210cc 100644 --- a/pandas/tests/indexes/test_interval.py +++ b/pandas/tests/indexes/test_interval.py @@ -1068,7 +1068,7 @@ def test_errors(self): interval_range(start='foo', periods=10) # invalid end - msg = 'end must be numeric or datetime-like, got \(0, 1\]' + msg = r'end must be numeric or datetime-like, got \(0, 1\]' with tm.assert_raises_regex(ValueError, msg): interval_range(end=Interval(0, 1), periods=10) diff --git a/pandas/tests/io/test_stata.py b/pandas/tests/io/test_stata.py index 94a0ac31e093e..d6bdb764f1c8e 100644 --- a/pandas/tests/io/test_stata.py +++ b/pandas/tests/io/test_stata.py @@ -1053,7 +1053,8 @@ def test_iterator(self): tm.assert_frame_equal(parsed.iloc[0:5, :], chunk) # GH12153 - from_chunks = pd.concat(read_stata(fname, chunksize=4)) + with read_stata(fname, chunksize=4) as itr: + from_chunks = pd.concat(itr) tm.assert_frame_equal(parsed, from_chunks) def test_read_chunks_115(self): @@ -1306,8 +1307,9 @@ def test_value_labels_iterator(self, write_index): df['A'] = df['A'].astype('category') with tm.ensure_clean() as path: df.to_stata(path, write_index=write_index) - dta_iter = pd.read_stata(path, iterator=True) - value_labels = dta_iter.value_labels() + + with pd.read_stata(path, iterator=True) as dta_iter: + value_labels = dta_iter.value_labels() assert value_labels == {'A': {0: 'A', 1: 'B', 2: 'C', 3: 'E'}} def test_set_index(self):