MulDataFrame.query#
- MulDataFrame.query(values=None, index=None, columns=None, **kwargs)#
Query the columns of the index, columns or values dataframe of a MulDataFrame alone or in combinations and return the intersection of the query results.
The function uses the
pandas.DataFrame.querymethod under the hood for the three quries.Parameters#
- valuesNone or str
The query string to evaluate for the values dataframe. Check DataFrame.query for detailed specification of this argument.
- indexNone or str
Same as the
valuesargument except that it is evaluated for the index dataframe.- columnsNone or str
Same as the
valuesargument except that it is evaluated for the columns dataframe.- kwargsany
The same
kwargspassed to DataFrame.query including theinplace=Falseargument. All three queries use the same set ofkwargs.
Returns#
- MulDataFrame or None
None if
inplace=True.
Examples#
>>> import pandas as pd >>> import muldataframe as md >>> 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 = md.MulDataFrame([[1,2],[8,9],[8,10]],index=index, columns=columns) >>> mf.query('c == 8') (2, 2) g 7 6 f 5 3 c d -------- --------- x y c d b 3 6 b 8 9 b 5 6 b 8 10 >>> md.query('c==8', index='x<=3', columns='f>3') (1, 1) g 7 f 5 c -------- ------ x y c b 3 6 b 8
MulDataFrame