From 472462938e902a4d749e05297ce2743c6a3ebd56 Mon Sep 17 00:00:00 2001 From: jreback Date: Fri, 24 Jan 2014 08:59:05 -0500 Subject: [PATCH] TST/DOC: addtl tests and docs for (GH6056) --- doc/source/release.rst | 2 +- doc/source/tutorials.rst | 6 +++--- doc/source/v0.13.1.txt | 22 ++++++++++++++++++++++ pandas/tests/test_indexing.py | 12 ++++++++++++ 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/doc/source/release.rst b/doc/source/release.rst index 4ed792afc0bcf..a69c0f8acaa46 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -136,7 +136,7 @@ Bug Fixes - Bug in Series.xs with a multi-index (:issue:`6018`) - Bug in Series construction of mixed type with datelike and an integer (which should result in object type and not automatic conversion) (:issue:`6028`) - - Possible segfault when chained indexing with an object array under numpy 1.7.1 (:issue:`6016`) + - Possible segfault when chained indexing with an object array under numpy 1.7.1 (:issue:`6026`, :issue:`6056`) - Bug in setting using fancy indexing a single element with a non-scalar (e.g. a list), (:issue:`6043`) - Regression in ``.get(None)`` indexing from 0.12 (:issue:`5652`) diff --git a/doc/source/tutorials.rst b/doc/source/tutorials.rst index 03d54e326e90c..6a1b288e10d38 100644 --- a/doc/source/tutorials.rst +++ b/doc/source/tutorials.rst @@ -1,8 +1,8 @@ .. _tutorials: -**************** -Pandas Tutorials -**************** +********* +Tutorials +********* This is a guide to many pandas tutorials, geared mainly for new users. diff --git a/doc/source/v0.13.1.txt b/doc/source/v0.13.1.txt index ee9e16d5f02f6..3efe79ce281db 100644 --- a/doc/source/v0.13.1.txt +++ b/doc/source/v0.13.1.txt @@ -15,6 +15,28 @@ There are several new or updated docs sections including: - :ref:`Tutorials`, a guide to community developed pandas tutorials. - :ref:`Pandas Ecosystem`, a guide to complementary projects built on top of pandas. +.. warning:: + + 0.13.1 fixes a bug that was caused by a combination of having numpy < 1.8, and doing + chained assignent on a string-like array. Please review :ref:`the docs`, + chained indexing can have unexpected results and should generally be avoided. + + This would previously segfault: + + .. ipython:: python + + df = DataFrame(dict(A = np.array(['foo','bar','bah','foo','bar']))) + df['A'].iloc[0] = np.nan + df + + The recommended way to do this type of assignment is: + + .. ipython:: python + + df = DataFrame(dict(A = np.array(['foo','bar','bah','foo','bar']))) + df.ix[0,'A'] = np.nan + df + API changes ~~~~~~~~~~~ diff --git a/pandas/tests/test_indexing.py b/pandas/tests/test_indexing.py index 8c4572cf63dd1..b4fa32ba3160c 100644 --- a/pandas/tests/test_indexing.py +++ b/pandas/tests/test_indexing.py @@ -2015,6 +2015,18 @@ def test_setitem_chained_setfault(self): df.response[mask] = 'none' assert_frame_equal(df, DataFrame({'response': mdata, 'response1' : data })) + # GH 6056 + expected = DataFrame(dict(A = [np.nan,'bar','bah','foo','bar'])) + df = DataFrame(dict(A = np.array(['foo','bar','bah','foo','bar']))) + df['A'].iloc[0] = np.nan + result = df.head() + assert_frame_equal(result, expected) + + df = DataFrame(dict(A = np.array(['foo','bar','bah','foo','bar']))) + df.A.iloc[0] = np.nan + result = df.head() + assert_frame_equal(result, expected) + def test_detect_chained_assignment(self): pd.set_option('chained_assignment','raise')