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

Drop Colum by index #21

Open
pjsgsy opened this issue Feb 2, 2025 · 1 comment
Open

Drop Colum by index #21

pjsgsy opened this issue Feb 2, 2025 · 1 comment

Comments

@pjsgsy
Copy link

pjsgsy commented Feb 2, 2025

Cool library. I got stopped pretty quick though as I wanted to drop the last column of a df by index. It looks like Drop is column header string only?

Is there a hack for this, like Drop(df.getcolname(df.ColCount)) ? If not, it kind of looks easy enough to add in the source that I could add that function, however, then I end up with a custom version and I'd rather not. I don't see a way to get a column name. From describe maybe? I'm guessing I'm missing something simple! Thanks.

///


/// Removes specified columns from the data frame.
///

/// List of column names to be removed.
///
public DataFrame Drop(params string[] colName)
{
//
var cols = new List<(string oldName, string newName)>();
foreach (var c in this.Columns)
{
if (colName.Contains(c))
continue;
cols.Add((c, null));
}

        return Create(cols.ToArray());
    }
@bhrnjica
Copy link
Owner

Hi pjsgsy,

unfortunately there is no such method.

Probably because original python pandas has no such method (I am not sure).

If you don't know already, there is a DevGuide that covers all functionalities in dataframe: https://github.com/bhrnjica/daany/blob/master/docs/DevGuide/developer_guide.md

Hope this help

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