@@ -108,7 +108,7 @@ class NDFrame(PandasObject, SelectionMixin):
108
108
axes : list
109
109
copy : boolean, default False
110
110
"""
111
- _internal_names = ['_data' , '_cacher' , '_item_cache' , '_cache' , 'is_copy ' ,
111
+ _internal_names = ['_data' , '_cacher' , '_item_cache' , '_cache' , '_is_copy ' ,
112
112
'_subtyp' , '_name' , '_index' , '_default_kind' ,
113
113
'_default_fill_value' , '_metadata' , '__array_struct__' ,
114
114
'__array_interface__' ]
@@ -117,7 +117,7 @@ class NDFrame(PandasObject, SelectionMixin):
117
117
_deprecations = frozenset (['as_blocks' , 'blocks' ,
118
118
'consolidate' , 'convert_objects' ])
119
119
_metadata = []
120
- is_copy = None
120
+ _is_copy = None
121
121
122
122
def __init__ (self , data , axes = None , copy = False , dtype = None ,
123
123
fastpath = False ):
@@ -132,10 +132,22 @@ def __init__(self, data, axes=None, copy=False, dtype=None,
132
132
for i , ax in enumerate (axes ):
133
133
data = data .reindex_axis (ax , axis = i )
134
134
135
- object .__setattr__ (self , 'is_copy ' , None )
135
+ object .__setattr__ (self , '_is_copy ' , None )
136
136
object .__setattr__ (self , '_data' , data )
137
137
object .__setattr__ (self , '_item_cache' , {})
138
138
139
+ @property
140
+ def is_copy (self ):
141
+ warnings .warn ("Attribute 'is_copy' will be removed in a future "
142
+ "version." , FutureWarning , stacklevel = 2 )
143
+ return self ._is_copy
144
+
145
+ @is_copy .setter
146
+ def is_copy (self , msg ):
147
+ warnings .warn ("Attribute 'is_copy' will be removed in a future "
148
+ "version." , FutureWarning , stacklevel = 2 )
149
+ self ._is_copy = msg
150
+
139
151
def _repr_data_resource_ (self ):
140
152
"""
141
153
Not a real Jupyter special repr method, but we use the same
@@ -2153,7 +2165,7 @@ def _get_item_cache(self, item):
2153
2165
res ._set_as_cached (item , self )
2154
2166
2155
2167
# for a chain
2156
- res .is_copy = self .is_copy
2168
+ res ._is_copy = self ._is_copy
2157
2169
return res
2158
2170
2159
2171
def _set_as_cached (self , item , cacher ):
@@ -2264,12 +2276,12 @@ def _set_item(self, key, value):
2264
2276
2265
2277
def _set_is_copy (self , ref = None , copy = True ):
2266
2278
if not copy :
2267
- self .is_copy = None
2279
+ self ._is_copy = None
2268
2280
else :
2269
2281
if ref is not None :
2270
- self .is_copy = weakref .ref (ref )
2282
+ self ._is_copy = weakref .ref (ref )
2271
2283
else :
2272
- self .is_copy = None
2284
+ self ._is_copy = None
2273
2285
2274
2286
def _check_is_chained_assignment_possible (self ):
2275
2287
"""
@@ -2288,7 +2300,7 @@ def _check_is_chained_assignment_possible(self):
2288
2300
self ._check_setitem_copy (stacklevel = 4 , t = 'referant' ,
2289
2301
force = True )
2290
2302
return True
2291
- elif self .is_copy :
2303
+ elif self ._is_copy :
2292
2304
self ._check_setitem_copy (stacklevel = 4 , t = 'referant' )
2293
2305
return False
2294
2306
@@ -2323,7 +2335,7 @@ def _check_setitem_copy(self, stacklevel=4, t='setting', force=False):
2323
2335
2324
2336
"""
2325
2337
2326
- if force or self .is_copy :
2338
+ if force or self ._is_copy :
2327
2339
2328
2340
value = config .get_option ('mode.chained_assignment' )
2329
2341
if value is None :
@@ -2333,23 +2345,23 @@ def _check_setitem_copy(self, stacklevel=4, t='setting', force=False):
2333
2345
# the copy weakref
2334
2346
try :
2335
2347
gc .collect (2 )
2336
- if not gc .get_referents (self .is_copy ()):
2337
- self .is_copy = None
2348
+ if not gc .get_referents (self ._is_copy ()):
2349
+ self ._is_copy = None
2338
2350
return
2339
2351
except Exception :
2340
2352
pass
2341
2353
2342
2354
# we might be a false positive
2343
2355
try :
2344
- if self .is_copy ().shape == self .shape :
2345
- self .is_copy = None
2356
+ if self ._is_copy ().shape == self .shape :
2357
+ self ._is_copy = None
2346
2358
return
2347
2359
except Exception :
2348
2360
pass
2349
2361
2350
2362
# a custom message
2351
- if isinstance (self .is_copy , string_types ):
2352
- t = self .is_copy
2363
+ if isinstance (self ._is_copy , string_types ):
2364
+ t = self ._is_copy
2353
2365
2354
2366
elif t == 'referant' :
2355
2367
t = ("\n "
0 commit comments