@@ -2666,9 +2666,10 @@ def test_cache_updating(self):
26662666 df .index = index
26672667
26682668 # setting via chained assignment
2669- def f ():
2670- df .loc [0 ]['z' ].iloc [0 ] = 1.
2671- self .assertRaises (com .SettingWithCopyError , f )
2669+ # but actually works, since everything is a view
2670+ df .loc [0 ]['z' ].iloc [0 ] = 1.
2671+ result = df .loc [(0 ,0 ),'z' ]
2672+ self .assertEqual (result , 1 )
26722673
26732674 # correct setting
26742675 df .loc [(0 ,0 ),'z' ] = 2
@@ -2710,6 +2711,28 @@ def test_setitem_cache_updating(self):
27102711 self .assertEqual (df .ix [0 ,'c' ], 0.0 )
27112712 self .assertEqual (df .ix [7 ,'c' ], 1.0 )
27122713
2714+ # GH 7084
2715+ # not updating cache on series setting with slices
2716+ out = DataFrame ({'A' : [0 , 0 , 0 ]}, index = date_range ('5/7/2014' , '5/9/2014' ))
2717+ df = DataFrame ({'C' : ['A' , 'A' , 'A' ], 'D' : [100 , 200 , 300 ]})
2718+
2719+ #loop through df to update out
2720+ six = Timestamp ('5/7/2014' )
2721+ eix = Timestamp ('5/9/2014' )
2722+ for ix , row in df .iterrows ():
2723+ out [row ['C' ]][six :eix ] = out [row ['C' ]][six :eix ] + row ['D' ]
2724+
2725+ expected = DataFrame ({'A' : [600 , 600 , 600 ]}, index = date_range ('5/7/2014' , '5/9/2014' ))
2726+ assert_frame_equal (out , expected )
2727+ assert_series_equal (out ['A' ], expected ['A' ])
2728+
2729+ out = DataFrame ({'A' : [0 , 0 , 0 ]}, index = date_range ('5/7/2014' , '5/9/2014' ))
2730+ for ix , row in df .iterrows ():
2731+ out .loc [six :eix ,row ['C' ]] += row ['D' ]
2732+
2733+ assert_frame_equal (out , expected )
2734+ assert_series_equal (out ['A' ], expected ['A' ])
2735+
27132736 def test_setitem_chained_setfault (self ):
27142737
27152738 # GH6026
0 commit comments