MCPcopy
hub / github.com/pandas-dev/pandas / remove

Method remove

pandas/io/pytables.py:1235–1288  ·  view source on GitHub ↗

Remove pandas object partially by specifying the where condition Parameters ---------- key : str Node to remove or delete rows from where : list of Term (or convertible) objects, optional start : integer (defaults to None), row number to

(self, key: str, where=None, start=None, stop=None)

Source from the content-addressed store, hash-verified

1233 )
1234
1235 def remove(self, key: str, where=None, start=None, stop=None) -> int | None:
1236 """
1237 Remove pandas object partially by specifying the where condition
1238
1239 Parameters
1240 ----------
1241 key : str
1242 Node to remove or delete rows from
1243 where : list of Term (or convertible) objects, optional
1244 start : integer (defaults to None), row number to start selection
1245 stop : integer (defaults to None), row number to stop selection
1246
1247 Returns
1248 -------
1249 number of rows removed (or None if not a Table)
1250
1251 Raises
1252 ------
1253 raises KeyError if key is not a valid store
1254
1255 """
1256 where = _ensure_term(where, scope_level=1)
1257 try:
1258 s = self.get_storer(key)
1259 except KeyError:
1260 # the key is not a valid store, re-raising KeyError
1261 raise
1262 except AssertionError:
1263 # surface any assertion errors for e.g. debugging
1264 raise
1265 except Exception as err:
1266 # In tests we get here with ClosedFileError, TypeError, and
1267 # _table_mod.NoSuchNodeError. TODO: Catch only these?
1268
1269 if where is not None:
1270 raise ValueError(
1271 "trying to remove a node with a non-None where clause!"
1272 ) from err
1273
1274 # we are actually trying to remove a node (with children)
1275 node = self.get_node(key)
1276 if node is not None:
1277 node._f_remove(recursive=True)
1278 return None
1279
1280 # remove the node
1281 if com.all_none(where, start, stop):
1282 s.group._f_remove(recursive=True)
1283 return None
1284
1285 # delete from the table
1286 if not s.is_table:
1287 raise ValueError("can only remove with where on objects written as tables")
1288 return s.delete(where=where, start=start, stop=stop)
1289
1290 def append(
1291 self,

Callers 15

__delitem__Method · 0.95
copyMethod · 0.95
test_multiple_open_closeFunction · 0.95
setup.pyFile · 0.45
htmlMethod · 0.45
zip_htmlMethod · 0.45
closeMethod · 0.45
_clean_index_namesMethod · 0.45
__init__Method · 0.45

Calls 4

get_storerMethod · 0.95
get_nodeMethod · 0.95
_ensure_termFunction · 0.85
deleteMethod · 0.45

Tested by 15

test_multiple_open_closeFunction · 0.76
test_dst_transitionsFunction · 0.36
test_categoricalFunction · 0.36
test_selectFunction · 0.36
test_api_default_formatFunction · 0.36
test_store_multiindexFunction · 0.36
test_removeFunction · 0.36
test_api_3Function · 0.36