0 votes
1 view
in Python by (6.1k 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 (12.1k points)

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

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

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

...