Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (19.9k points)

In pandas, I can fill a single column with 0 as follows:

df['COL'].fillna(0, inplace=True)

is it possible to fill multiple columns in same step?

1 Answer

0 votes
by (25.1k points)

Instead of col just pass a list of columns. Like this:

columns = ["col1", "col2", "col3"]

df[columns].fillna(0, inplace=True)

Browse Categories

...