Skip to content

Why does set_column exist? #116

Closed
@MarcoGorelli

Description

@MarcoGorelli

I find this method a bit odd for two reasons.

First, it does two things: either replaces a column, or inserts a new one. This seems at odds with the rest of the Standard, which is typically quite strict and minimal.

Second, it can be implemented in terms of other Standard methods in just a few lines of code:

    def set_column(self, label: str, value: Column) -> DataFrame:
        columns = self.get_column_names()
        if label in columns:
            idx = columns.index(label)
            return self.drop_column(label).insert(idx, label, value)
        return self.insert(len(columns), label, value)

Is this right?

If so, I'd suggest dropping it. Otherwise, if we're going to keep it just because it's convenient, then I'd argue that we should also have value_counts

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions