Skip to content

Commit d925966

Browse files
committed
Merge pull request #3533 from jreback/GH3492
BUG: Fixed bug in mixed frame assignment with aligned series (GH3492)
2 parents 2c3a74e + c5c3da7 commit d925966

File tree

4 files changed

+19
-2
lines changed

4 files changed

+19
-2
lines changed

RELEASE.rst

+2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ pandas 0.11.1
7878
(removed warning) (GH2786_), and fix (GH3230_)
7979
- Fix to_csv to handle non-unique columns (GH3495_)
8080
- Fixed bug in groupby with empty series referencing a variable before assignment. (GH3510_)
81+
- Fixed bug in mixed-frame assignment with aligned series (GH3492_)
8182

8283
.. _GH3164: https://github.com/pydata/pandas/issues/3164
8384
.. _GH2786: https://github.com/pydata/pandas/issues/2786
@@ -103,6 +104,7 @@ pandas 0.11.1
103104
.. _GH3448: https://github.com/pydata/pandas/issues/3448
104105
.. _GH3449: https://github.com/pydata/pandas/issues/3449
105106
.. _GH3495: https://github.com/pydata/pandas/issues/3495
107+
.. _GH3492: https://github.com/pydata/pandas/issues/3492
106108
.. _GH3493: https://github.com/pydata/pandas/issues/3493
107109

108110

doc/source/v0.11.1.txt

+1
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ on GitHub for a complete list.
2121

2222
.. _GH2437: https://github.com/pydata/pandas/issues/2437
2323
.. _GH3477: https://github.com/pydata/pandas/issues/3477
24+
.. _GH3492: https://github.com/pydata/pandas/issues/3492

pandas/core/indexing.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,7 @@ def setter(item, v):
124124
values = data.values
125125
if np.prod(values.shape):
126126
result, changed = com._maybe_upcast_indexer(values,plane_indexer,v,dtype=getattr(data,'dtype',None))
127-
if changed:
128-
self.obj[item] = result
127+
self.obj[item] = result
129128

130129
labels = item_labels[het_idx]
131130

pandas/tests/test_indexing.py

+15
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,21 @@ def test_dups_fancy_indexing(self):
784784

785785
assert_frame_equal(df,result)
786786

787+
def test_indexing_mixed_frame_bug(self):
788+
789+
# GH3492
790+
df=DataFrame({'a':{1:'aaa',2:'bbb',3:'ccc'},'b':{1:111,2:222,3:333}})
791+
792+
# this works, new column is created correctly
793+
df['test']=df['a'].apply(lambda x: '_' if x=='aaa' else x)
794+
795+
# this does not work, ie column test is not changed
796+
idx=df['test']=='_'
797+
temp=df.ix[idx,'a'].apply(lambda x: '-----' if x=='aaa' else x)
798+
df.ix[idx,'test']=temp
799+
self.assert_(df.iloc[0,2] == '-----')
800+
801+
#if I look at df, then element [0,2] equals '_'. If instead I type df.ix[idx,'test'], I get '-----', finally by typing df.iloc[0,2] I get '_'.
787802

788803
if __name__ == '__main__':
789804
import nose

0 commit comments

Comments
 (0)