Skip to content

BUG: Fixed bug in mixed frame assignment with aligned series (GH3492) #3533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions RELEASE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ pandas 0.11.1
(removed warning) (GH2786_), and fix (GH3230_)
- Fix to_csv to handle non-unique columns (GH3495_)
- Fixed bug in groupby with empty series referencing a variable before assignment. (GH3510_)
- Fixed bug in mixed-frame assignment with aligned series (GH3492_)

.. _GH3164: https://github.com/pydata/pandas/issues/3164
.. _GH2786: https://github.com/pydata/pandas/issues/2786
Expand All @@ -103,6 +104,7 @@ pandas 0.11.1
.. _GH3448: https://github.com/pydata/pandas/issues/3448
.. _GH3449: https://github.com/pydata/pandas/issues/3449
.. _GH3495: https://github.com/pydata/pandas/issues/3495
.. _GH3492: https://github.com/pydata/pandas/issues/3492
.. _GH3493: https://github.com/pydata/pandas/issues/3493


Expand Down
1 change: 1 addition & 0 deletions doc/source/v0.11.1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ on GitHub for a complete list.

.. _GH2437: https://github.com/pydata/pandas/issues/2437
.. _GH3477: https://github.com/pydata/pandas/issues/3477
.. _GH3492: https://github.com/pydata/pandas/issues/3492
3 changes: 1 addition & 2 deletions pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ def setter(item, v):
values = data.values
if np.prod(values.shape):
result, changed = com._maybe_upcast_indexer(values,plane_indexer,v,dtype=getattr(data,'dtype',None))
if changed:
self.obj[item] = result
self.obj[item] = result

labels = item_labels[het_idx]

Expand Down
15 changes: 15 additions & 0 deletions pandas/tests/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,21 @@ def test_dups_fancy_indexing(self):

assert_frame_equal(df,result)

def test_indexing_mixed_frame_bug(self):

# GH3492
df=DataFrame({'a':{1:'aaa',2:'bbb',3:'ccc'},'b':{1:111,2:222,3:333}})

# this works, new column is created correctly
df['test']=df['a'].apply(lambda x: '_' if x=='aaa' else x)

# this does not work, ie column test is not changed
idx=df['test']=='_'
temp=df.ix[idx,'a'].apply(lambda x: '-----' if x=='aaa' else x)
df.ix[idx,'test']=temp
self.assert_(df.iloc[0,2] == '-----')

#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 '_'.

if __name__ == '__main__':
import nose
Expand Down