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

DataFrame - Drop multiple columns #6497

Open
Tracked by #6144
luisquintanilla opened this issue Dec 1, 2022 · 3 comments
Open
Tracked by #6144

DataFrame - Drop multiple columns #6497

luisquintanilla opened this issue Dec 1, 2022 · 3 comments

Comments

@luisquintanilla
Copy link
Contributor

No description provided.

@ghost ghost added the untriaged New issue has not been triaged label Dec 1, 2022
@luisquintanilla luisquintanilla removed the untriaged New issue has not been triaged label Dec 1, 2022
@amine-aboufirass
Copy link

amine-aboufirass commented Mar 27, 2023

@luisquintanilla Is there currently a way to drop just one column?

@IntegerMan
Copy link

@amine-aboufirass you can do the following currently:

// Drop the ID column
df.Columns.Remove("ID");

@IntegerMan
Copy link

A temporary workaround around removing multiple at once would be logic like this:

// Remove unnecessary columns
string[] columnsToDrop = new string[] { "first_name", "last_name", "name", "player_id", "index", "current_club_id", "player_code", "city_of_birth", "country_of_citizenship", "date_of_birth", "contract_expiration_date", "agent_name", "image_url", "url", "current_club_domestic_competition_id", "current_club_name" };
foreach (string columnName in columnsToDrop) {
    df.Columns.Remove(columnName);
}

You could wrap this into a static class with a static extension method that took in a params array of strings if you wanted, then you could call df.Remove("A", "B", "C"); via your extension method.

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

3 participants