bodo.pandas.BodoDataFrame.filter¶
Subset the BodoDataFrame according to the specified (column) labels. This does not raise an error if a provided label is not in the dataframe.Parameters
-
items: list-like, default None: Keep column labels that are in
items. -
like : str, default None: Keep column labels for which
likeis found in the column label string. -
regex: str (regular expression), default None: Keep column labels for which re.search(
regex, label) == True. -
Exactly one of the above parameters must be provided, else a
TypeErrorwill be raised. -
Setting the
axisparameter will trigger a fallback topandas.DataFrame.filterif a value other thanNone,1, or"columns"is provided. Returns
-
BodoDataFrame
Example
Using items:
import bodo.pandas as bd
bdf = bd.DataFrame(
{
"A": [0, 1, 2, 3, 4],
"BB": [5, 6, 7, 8, 9],
"CAC": [10, 11, 12, 13, 14]
}
)
bdf_filtered = bdf.filter(items=("BB", "CAC", "D"))
print(bdf_filtered)
Output:
Using like:
import bodo.pandas as bd
bdf = bd.DataFrame(
{
"A": [0, 1, 2, 3, 4],
"BB": [5, 6, 7, 8, 9],
"CAC": [10, 11, 12, 13, 14]
}
)
bdf_filtered = bdf.filter(like="A")
print(bdf_filtered)
Output: