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

[EHN] let column_name or column_names support callback type #1115

Open
Zeroto521 opened this issue Jun 13, 2022 · 1 comment
Open

[EHN] let column_name or column_names support callback type #1115

Zeroto521 opened this issue Jun 13, 2022 · 1 comment

Comments

@Zeroto521
Copy link
Member

Brief Description

There always has an option called column_name or column_names.
It's used to select the columns of df.
The type could be a single value like Hashable and list values likes Iterable[Hashable].
And this idea is to support callback type.

Originally posted by @ericmjl in #1112 (comment)

Example API

An implicit style and also a trick to select columns.

Select columns Using callable type Using Iterable type df.columns
Select the first three columns lambda df: df.columns[:3] ['a', 'b', 'c'] pd.Index(list('abcde'))
Select str type columns lambda df: [i for i in df.columns if instance(i, str)] ['a', 'b', 'c'] pd.Index(['a', 'b', 'c', 1])
@samukweku
Copy link
Collaborator

For this, we can pass callables to select_columns

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants