Skip to content

Commit 77f1672

Browse files
committed
Merge pull request #6058 from jreback/iloc_segfault
TST/DOC: addtl tests and docs for (GH6056)
2 parents 4dcecb0 + 4724629 commit 77f1672

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed

doc/source/release.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ Bug Fixes
136136
- Bug in Series.xs with a multi-index (:issue:`6018`)
137137
- Bug in Series construction of mixed type with datelike and an integer (which should result in
138138
object type and not automatic conversion) (:issue:`6028`)
139-
- Possible segfault when chained indexing with an object array under numpy 1.7.1 (:issue:`6016`)
139+
- Possible segfault when chained indexing with an object array under numpy 1.7.1 (:issue:`6026`, :issue:`6056`)
140140
- Bug in setting using fancy indexing a single element with a non-scalar (e.g. a list),
141141
(:issue:`6043`)
142142
- Regression in ``.get(None)`` indexing from 0.12 (:issue:`5652`)

doc/source/tutorials.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
.. _tutorials:
22

3-
****************
4-
Pandas Tutorials
5-
****************
3+
*********
4+
Tutorials
5+
*********
66

77
This is a guide to many pandas tutorials, geared mainly for new users.
88

doc/source/v0.13.1.txt

+22
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,28 @@ There are several new or updated docs sections including:
1515
- :ref:`Tutorials<tutorials>`, a guide to community developed pandas tutorials.
1616
- :ref:`Pandas Ecosystem<ecosystem>`, a guide to complementary projects built on top of pandas.
1717

18+
.. warning::
19+
20+
0.13.1 fixes a bug that was caused by a combination of having numpy < 1.8, and doing
21+
chained assignent on a string-like array. Please review :ref:`the docs<indexing.view_versus_copy>`,
22+
chained indexing can have unexpected results and should generally be avoided.
23+
24+
This would previously segfault:
25+
26+
.. ipython:: python
27+
28+
df = DataFrame(dict(A = np.array(['foo','bar','bah','foo','bar'])))
29+
df['A'].iloc[0] = np.nan
30+
df
31+
32+
The recommended way to do this type of assignment is:
33+
34+
.. ipython:: python
35+
36+
df = DataFrame(dict(A = np.array(['foo','bar','bah','foo','bar'])))
37+
df.ix[0,'A'] = np.nan
38+
df
39+
1840
API changes
1941
~~~~~~~~~~~
2042

pandas/tests/test_indexing.py

+12
Original file line numberDiff line numberDiff line change
@@ -2015,6 +2015,18 @@ def test_setitem_chained_setfault(self):
20152015
df.response[mask] = 'none'
20162016
assert_frame_equal(df, DataFrame({'response': mdata, 'response1' : data }))
20172017

2018+
# GH 6056
2019+
expected = DataFrame(dict(A = [np.nan,'bar','bah','foo','bar']))
2020+
df = DataFrame(dict(A = np.array(['foo','bar','bah','foo','bar'])))
2021+
df['A'].iloc[0] = np.nan
2022+
result = df.head()
2023+
assert_frame_equal(result, expected)
2024+
2025+
df = DataFrame(dict(A = np.array(['foo','bar','bah','foo','bar'])))
2026+
df.A.iloc[0] = np.nan
2027+
result = df.head()
2028+
assert_frame_equal(result, expected)
2029+
20182030
def test_detect_chained_assignment(self):
20192031

20202032
pd.set_option('chained_assignment','raise')

0 commit comments

Comments
 (0)