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

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

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

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

Welcome to Intellipaat Community. Get your technical queries answered by top developers !