Skip to content

ENH: dropna should accept single column as string in subset argument #41021

Closed
@erfannariman

Description

@erfannariman

Is your feature request related to a problem?

When giving a string in the subset argument to dropna based on a single column, we get an error:

Index(...) must be called with a collection of some kind, 'C' was passed

Describe the solution you'd like

DataFrame.dropna should accept a single column subset as a string just like DataFrame.drop_duplicates

API breaking implications

None I could think of

df = pd.DataFrame({"A": [1, 1, 3], "B": list("abc"), "C": [4, np.NaN, 5]})
print(df)

   A  B    C
0  1  a  4.0
1  2  b  NaN
2  3  c  5.0

df = df.dropna(subset="C")
print(df)

   A  B    C
0  1  a  4.0
2  3  c  5.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions