Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] generic select function #1187

Merged
merged 13 commits into from
Nov 8, 2022
Prev Previous commit
Next Next commit
return whatever user passes, even if they r duplicates
  • Loading branch information
samukweku committed Nov 2, 2022
commit f6a6e6cd065ce94badad77c89c5a89a4dbc12af6
5 changes: 1 addition & 4 deletions janitor/functions/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from pandas.core.dtypes.generic import ABCPandasArray, ABCExtensionArray
from pandas.core.common import is_bool_indexer


import pandas as pd
from janitor.utils import check, _expand_grid
from pandas.api.types import (
Expand Down Expand Up @@ -508,9 +507,7 @@ def _index_dispatch(arg, df, axis): # noqa: F811
elif isinstance(arr, int):
arr = [arr]
contents.append(arr)
contents = np.concatenate(contents)
# remove possible duplicates
return pd.unique(contents)
return np.concatenate(contents)


def _select(
Expand Down
4 changes: 2 additions & 2 deletions tests/functions/test_select_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def test_select_column_names_missing_columns(dataframe, columns):
dataframe.select_columns(columns)


@pytest.mark.xfail(reason="return whatever user passes")
@pytest.mark.functions
@pytest.mark.parametrize(
"invert,expected",
Expand Down Expand Up @@ -394,8 +395,7 @@ def test_boolean_list_multi(multiindex):

def test_series_multi(multiindex):
"""Test pd.Series output on a MultiIndex"""
mapp = pd.Series(["bar"])
expected = multiindex.select_columns(mapp, slice("foo"))
expected = multiindex.select_columns(pd.Series("bar"), slice("baz", "foo"))
actual = multiindex.loc(axis=1)["bar":"foo"]
assert_frame_equal(expected, actual)

Expand Down