File tree 1 file changed +17
-1
lines changed
1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 5
5
from pandas import (Series , DataFrame , MultiIndex ,
6
6
Int64Index , UInt64Index , Float64Index ,
7
7
IntervalIndex , CategoricalIndex ,
8
- IndexSlice , concat , date_range )
8
+ IndexSlice , concat , date_range , option_context )
9
9
10
10
11
11
class NumericSeriesIndexing :
@@ -335,4 +335,20 @@ def time_assign_with_setitem(self):
335
335
self .df [i ] = np .random .randn (self .N )
336
336
337
337
338
+ class ChainIndexing :
339
+
340
+ params = [None , 'warn' ]
341
+ param_names = ['mode' ]
342
+
343
+ def setup (self , mode ):
344
+ self .N = 1000000
345
+
346
+ def time_chained_indexing (self , mode ):
347
+ with warnings .catch_warnings (record = True ):
348
+ with option_context ('mode.chained_assignment' , mode ):
349
+ df = DataFrame ({'A' : np .arange (self .N ), 'B' : 'foo' })
350
+ df2 = df [df .A > self .N // 2 ]
351
+ df2 ['C' ] = 1.0
352
+
353
+
338
354
from .pandas_vb_common import setup # noqa: F401
You can’t perform that action at this time.
0 commit comments