MulDataFrame.drop#
- MulDataFrame.drop(labels, mloc=None, inplace=False, axis=0)#
Remove rows or columns from MulDataFrame by labels.
Remove rows or columns by specifying labels and corresponding axis. Labels can be primary index/columns labels or labels in a column in the index/columns dataframe.
Parameters#
- labelssingle label or list-like
Primary index (
axis=0) or columns (axis=1) labels ifmloc=Noneor labels in a column of the index or columns dataframe specified bymloc.- mlocNone, str, number, or hashable object
Column name in the index (
axis=0) or columns (axis=1) dataframe. ifmloc=None, use the primary index or columns to select removed rows or columns. Otherwise, use the labels in the specified column to select removed rows or columns.- inplacebool, default False
Whether to modify the MulDataFrame inplace or return a new MulDataFrame with rows or columns removed.
- axis{0,1}, default 0
Whether to remove rows (
axis=0) or columns (axis=1).
Returns#
- MulSeries or None
returns
Noneifinplace=True.
Examples#
>>> index = pd.DataFrame([[1,2],[3,6],[5,6]], index=['a','b','b'], columns=['x','y']) >>> columns = pd.DataFrame([[5,7],[3,6]], index=['c','d'], columns=['f','g']) >>> mf = MulDataFrame([[1,2],[8,9],[8,10]],index=index, columns=columns) >>> mf.drop('b') (1, 2) g 7 6 f 5 3 c d -------- --------- x y c d a 1 2 a 1 2 >>> mf.drop(5,mloc='f',inplace=True,axis=1) >>> mf (3, 1) g 6 f 3 d -------- ------ x y d a 1 2 a 2 b 3 6 b 9 b 5 6 b 10
MulDataFrame