@@ -95,8 +95,7 @@ def __sizeof__(self):
95
95
either a value or Series of values
96
96
"""
97
97
if hasattr (self , "memory_usage" ):
98
- # pandas\core\base.py:84: error: "PandasObject" has no attribute
99
- # "memory_usage" [attr-defined]
98
+ # error: "PandasObject" has no attribute "memory_usage"
100
99
mem = self .memory_usage (deep = True ) # type: ignore[attr-defined]
101
100
return int (mem if is_scalar (mem ) else mem .sum ())
102
101
@@ -206,17 +205,14 @@ def _selection_list(self):
206
205
207
206
@cache_readonly
208
207
def _selected_obj (self ):
209
- # pandas\core\base.py:195: error: "SelectionMixin" has no attribute
210
- # "obj" [attr-defined]
208
+ # error: "SelectionMixin" has no attribute "obj"
211
209
if self ._selection is None or isinstance (
212
210
self .obj , ABCSeries # type: ignore[attr-defined]
213
211
):
214
- # pandas\core\base.py:194: error: "SelectionMixin" has no attribute
215
- # "obj" [attr-defined]
212
+ # error: "SelectionMixin" has no attribute "obj"
216
213
return self .obj # type: ignore[attr-defined]
217
214
else :
218
- # pandas\core\base.py:204: error: "SelectionMixin" has no attribute
219
- # "obj" [attr-defined]
215
+ # error: "SelectionMixin" has no attribute "obj"
220
216
return self .obj [self ._selection ] # type: ignore[attr-defined]
221
217
222
218
@cache_readonly
@@ -225,57 +221,48 @@ def ndim(self) -> int:
225
221
226
222
@cache_readonly
227
223
def _obj_with_exclusions (self ):
228
- # pandas\core\base.py:209: error: "SelectionMixin" has no attribute
229
- # "obj" [attr-defined]
224
+ # error: "SelectionMixin" has no attribute "obj"
230
225
if self ._selection is not None and isinstance (
231
226
self .obj , ABCDataFrame # type: ignore[attr-defined]
232
227
):
233
- # pandas\core\base.py:217: error: "SelectionMixin" has no attribute
234
- # "obj" [attr-defined]
228
+ # error: "SelectionMixin" has no attribute "obj"
235
229
return self .obj .reindex ( # type: ignore[attr-defined]
236
230
columns = self ._selection_list
237
231
)
238
232
239
- # pandas\core\base.py:207: error: "SelectionMixin" has no attribute
240
- # "exclusions" [attr-defined]
233
+ # error: "SelectionMixin" has no attribute "exclusions"
241
234
if len (self .exclusions ) > 0 : # type: ignore[attr-defined]
242
- # pandas\core\base.py:208: error: "SelectionMixin" has no attribute
243
- # "obj" [attr-defined]
244
-
245
- # pandas\core\base.py:208: error: "SelectionMixin" has no attribute
246
- # "exclusions" [attr-defined]
235
+ # error: "SelectionMixin" has no attribute "obj"
236
+ # error: "SelectionMixin" has no attribute "exclusions"
247
237
return self .obj .drop (self .exclusions , axis = 1 ) # type: ignore[attr-defined]
248
238
else :
249
- # pandas\core\base.py:210: error: "SelectionMixin" has no attribute
250
- # "obj" [attr-defined]
239
+ # error: "SelectionMixin" has no attribute "obj"
251
240
return self .obj # type: ignore[attr-defined]
252
241
253
242
def __getitem__ (self , key ):
254
243
if self ._selection is not None :
255
244
raise IndexError (f"Column(s) { self ._selection } already selected" )
256
245
257
246
if isinstance (key , (list , tuple , ABCSeries , ABCIndex , np .ndarray )):
258
- # pandas\core\base.py:217: error: "SelectionMixin" has no attribute
259
- # "obj" [attr-defined]
247
+ # error: "SelectionMixin" has no attribute "obj"
260
248
if len (
261
249
self .obj .columns .intersection (key ) # type: ignore[attr-defined]
262
250
) != len (key ):
263
- # pandas\core\base.py:218: error: "SelectionMixin" has no
264
- # attribute "obj" [attr-defined]
251
+ # error: "SelectionMixin" has no attribute "obj"
265
252
bad_keys = list (
266
253
set (key ).difference (self .obj .columns ) # type: ignore[attr-defined]
267
254
)
268
255
raise KeyError (f"Columns not found: { str (bad_keys )[1 :- 1 ]} " )
269
256
return self ._gotitem (list (key ), ndim = 2 )
270
257
271
258
elif not getattr (self , "as_index" , False ):
272
- # error: "SelectionMixin" has no attribute "obj" [attr-defined]
259
+ # error: "SelectionMixin" has no attribute "obj"
273
260
if key not in self .obj .columns : # type: ignore[attr-defined]
274
261
raise KeyError (f"Column not found: { key } " )
275
262
return self ._gotitem (key , ndim = 2 )
276
263
277
264
else :
278
- # error: "SelectionMixin" has no attribute "obj" [attr-defined]
265
+ # error: "SelectionMixin" has no attribute "obj"
279
266
if key not in self .obj : # type: ignore[attr-defined]
280
267
raise KeyError (f"Column not found: { key } " )
281
268
return self ._gotitem (key , ndim = 1 )
@@ -601,8 +588,7 @@ def to_numpy(
601
588
dtype='datetime64[ns]')
602
589
"""
603
590
if is_extension_array_dtype (self .dtype ):
604
- # pandas\core\base.py:837: error: Too many arguments for "to_numpy"
605
- # of "ExtensionArray" [call-arg]
591
+ # error: Too many arguments for "to_numpy" of "ExtensionArray"
606
592
return self .array .to_numpy ( # type: ignore[call-arg]
607
593
dtype , copy = copy , na_value = na_value , ** kwargs
608
594
)
@@ -914,13 +900,11 @@ def _map_values(self, mapper, na_action=None):
914
900
# use the built in categorical series mapper which saves
915
901
# time by mapping the categories instead of all values
916
902
917
- # pandas\core\base.py:893: error: Incompatible types in
918
- # assignment (expression has type "Categorical", variable has
919
- # type "IndexOpsMixin") [assignment]
903
+ # error: Incompatible types in assignment (expression has type
904
+ # "Categorical", variable has type "IndexOpsMixin")
920
905
self = cast ("Categorical" , self ) # type: ignore[assignment]
921
- # pandas\core\base.py:894: error: Item "ExtensionArray" of
922
- # "Union[ExtensionArray, Any]" has no attribute "map"
923
- # [union-attr]
906
+ # error: Item "ExtensionArray" of "Union[ExtensionArray, Any]" has no
907
+ # attribute "map"
924
908
return self ._values .map (mapper ) # type: ignore[union-attr]
925
909
926
910
values = self ._values
@@ -938,8 +922,7 @@ def _map_values(self, mapper, na_action=None):
938
922
raise NotImplementedError
939
923
map_f = lambda values , f : values .map (f )
940
924
else :
941
- # pandas\core\base.py:1142: error: "IndexOpsMixin" has no attribute
942
- # "astype" [attr-defined]
925
+ # error: "IndexOpsMixin" has no attribute "astype"
943
926
values = self .astype (object )._values # type: ignore[attr-defined]
944
927
if na_action == "ignore" :
945
928
map_f = lambda values , f : lib .map_infer_mask (
@@ -1177,8 +1160,7 @@ def memory_usage(self, deep=False):
1177
1160
are not components of the array if deep=False or if used on PyPy
1178
1161
"""
1179
1162
if hasattr (self .array , "memory_usage" ):
1180
- # pandas\core\base.py:1379: error: "ExtensionArray" has no
1181
- # attribute "memory_usage" [attr-defined]
1163
+ # error: "ExtensionArray" has no attribute "memory_usage"
1182
1164
return self .array .memory_usage (deep = deep ) # type: ignore[attr-defined]
1183
1165
1184
1166
v = self .array .nbytes
@@ -1313,8 +1295,7 @@ def searchsorted(self, value, side="left", sorter=None) -> np.ndarray:
1313
1295
1314
1296
def drop_duplicates (self , keep = "first" ):
1315
1297
duplicated = self .duplicated (keep = keep )
1316
- # pandas\core\base.py:1507: error: Value of type "IndexOpsMixin" is not
1317
- # indexable [index]
1298
+ # error: Value of type "IndexOpsMixin" is not indexable
1318
1299
return self [~ duplicated ] # type: ignore[index]
1319
1300
1320
1301
def duplicated (self , keep = "first" ):
0 commit comments