Came across this page while looking for an answer to this problem, but didn't like the existing answers. I ended up finding something better in the DataFrame.fillna documentation, and figured I'd contribute for anyone else that happens upon this.

If you have multiple columns, but only want to replace the NaN in a subset of them, you can use:

df.fillna({'Name':'.', 'City':'.'}, inplace=True)

This also allows you to specify different replacements for each column. And if you want to go ahead and fill all remaining NaN values, you can just throw another fillna on the end:

df.fillna({'Name':'.', 'City':'.'}, inplace=True).fillna(0, inplace=True)

Edit (22 Apr 2021)

Functionality (presumably / apparently) changed since original post, and you can no longer chain 2 inplace fillna() operations. You can still chain, but now must assign that chain to the df instead of modifying in place, e.g. like so:

df = df.fillna({'Name':'.', 'City':'.'}).fillna(0)
Answer from Rob Bulmahn on Stack Overflow
Discussions

Pandas: is there a way to do fillna() on multiple columns at once?

It should be as simple as df = df.fillna(value=0), with whatever value you want instead of 0. I'm using 17.1.

More on reddit.com
🌐 r/learnpython
12
4
March 5, 2016
Pandas: Is it possible to use the fillna() method using a calculation between two columns of a specific row?
The way to do this would be to just calculate a series with all of the values, then pass the name of that series to fillna() as the first argument. Something like df["fill_value"] = df["Unit_Cost"] * df["Quantity"] df["Total_Cost"] = df["Total_Cost"].fillna(df["fill_value"]) More on reddit.com
🌐 r/learnpython
1
0
February 23, 2025
python - Using pandas fillna() on multiple columns - Stack Overflow
I'm a new pandas user (as of yesterday), and have found it at times both convenient and frustrating. My current frustration is in trying to use df.fillna() on multiple columns of a dataframe. For More on stackoverflow.com
🌐 stackoverflow.com
August 1, 2013
Fillna with inplace=True not working with multiple columns but fine with single column
pandas.DataFrame.fillna with inplace=True is not working with multiple columns. It only works on a single column. More on github.com
🌐 github.com
2
July 9, 2019
🌐
Statology
statology.org › home › how to fill na values for multiple columns in pandas
How to Fill NA Values for Multiple Columns in Pandas
January 17, 2021 - The following code shows how to fill in missing values with a zero for all columns in the DataFrame: #replace all missing values with zero df.fillna(value=0, inplace=True) #view DataFrame print(df) team points assists rebounds 0 A 25.0 5.0 11 1 0 0.0 7.0 8 2 B 15.0 7.0 10 3 B 0.0 9.0 6 4 B 19.0 12.0 6 5 C 23.0 9.0 5 6 C 25.0 0.0 9 7 C 29.0 4.0 12
🌐
Bobby Hadz
bobbyhadz.com › blog › pandas-fillna-only-some-specific-columns-in-dataframe
Panda: Using fillna() with specific columns in a DataFrame | bobbyhadz
April 12, 2024 - Once we've selected the multiple columns, we can call the fillna() method with the replacement. The code sample used the "NOT_AVAILABLE" string for the replacement, but you can use any other value.
🌐
Linux find Examples
queirozf.com › entries › pandas-fillna-examples-filling-in-missing-data
Pandas Fillna Examples: Filling in Missing Data
May 29, 2023 - AFTER: only values in the row indexed by 1 were filled with "--" (other rows left unchanged) To fill nulls in multiple specific columns, pass a dict to fillna · import pandas as pd import numpy as np df = pd.DataFrame({ 'col1': [1.0, 2.0, 3.0, np.nan, None ], 'col2': [1, 2, 3, 4, 5 ], 'col3': ...
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.fillna.html
pandas.DataFrame.fillna — pandas 3.0.2 documentation
Replace all NaN elements in column ‘A, ‘B’, ‘C’, and ‘D’, with 0, 1, 2, and 3 respectively. >>> values = {"A": 0, "B": 1, "C": 2, "D": 3} >>> df.fillna(value=values) A B C D 0 0.0 2.0 2.0 0.0 1 3.0 4.0 2.0 1.0 2 0.0 1.0 2.0 3.0 3 0.0 3.0 2.0 4.0 · Only replace the first NaN element.
🌐
Spark By {Examples}
sparkbyexamples.com › home › pandas › pandas.dataframe.fillna() – explained by examples
pandas.DataFrame.fillna() - Explained by Examples - Spark By {Examples}
June 26, 2025 - pandas.DataFrame.fillna() method is used to fill column (one or multiple columns) containing NA/NaN/None with 0, empty, blank, or any specified values
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › fillna-in-multiple-columns-in-place-in-python-pandas
Fillna in multiple columns in place in Python Pandas - GeeksforGeeks
We can use fillna() function to impute the missing values of a data frame to every column defined by a dictionary of values. The limitation of this method is that we can only use constant values to be filled.
Published   September 13, 2022
🌐
Reddit
reddit.com › r/learnpython › pandas: is there a way to do fillna() on multiple columns at once?
r/learnpython on Reddit: Pandas: is there a way to do fillna() on multiple columns at once?
March 5, 2016 -

Heya, I was wondering if there's a way to fillna on multiple columns at once in a Pandas' DataFrame. Currently I just do them one by one, row after row. Seems like there should be an easier way. If it helps, the fillna value I want to use is the same for all columns.

Looking forward to hearing your tricks!

UPDATE [3/5]: to be clear, I want to fillna multiple columns, which are just a subset of the original df (that is, there are some columns I do not want/need to fillna).

🌐
Reddit
reddit.com › r/learnpython › pandas: is it possible to use the fillna() method using a calculation between two columns of a specific row?
r/learnpython on Reddit: Pandas: Is it possible to use the fillna() method using a calculation between two columns of a specific row?
February 23, 2025 -

I am currently cleaning data using Pandas of bike sales.

Each bike sale is broken down into: 'Quantity_Sold' 'Total_Cost', 'Total_Revenue', 'Total_Profit' , 'Unit_Cost', 'Unit_Price', 'Unit_Profit'.

There are Null values for some of these columns, however, it is possible to calculate the missing column's valuing using the other remaining columns that are filled. For example a null "Total_Cost" column can be calculated via "Unit_Cost"*"Quantity" etc.

How do I use the fillna() method to do this, so I can fill in the columns without resorting to mean, median and averages?

🌐
Statology
statology.org › home › pandas: how to use fillna() with specific columns
Pandas: How to Use fillna() with Specific Columns
June 10, 2022 - #replace NaNs with zeros in 'rating' column df['rating'] = df['rating'].fillna(0) #view DataFrame df rating points assists rebounds 0 0.0 25.0 5.0 11 1 85.0 NaN 7.0 8 2 0.0 14.0 7.0 10 3 88.0 16.0 NaN 6 4 94.0 27.0 5.0 6 5 90.0 20.0 7.0 9 6 76.0 12.0 6.0 6 7 75.0 15.0 9.0 10 8 87.0 14.0 9.0 10 9 86.0 19.0 5.0 7 · Notice that the NaN values have been replaced only in the “rating” column and every other column remained untouched.
🌐
Python Forum
python-forum.io › thread-34498.html
Apply fillna to multiple columns in dataframe
August 4, 2021 - Hi all, I have just started with python and in particular pandas and the following question has come up in my mind a few times and I am wondering, if I am doing anything wrong? In this particular example, I am trying to fill NAs using fillna and va...
🌐
TutorialsPoint
tutorialspoint.com › fillna-in-multiple-columns-in-place-in-python-pandas
Fillna in Multiple Columns in Place in Python Pandas
February 27, 2025 - You can use the fillna() method in Pandas to fill missing values in single or multiple columns of a DataFrame, or can be used to fill missing values in a series too. You can specify the value to be used for filling and how to fill the values with various arguments.
🌐
Delft Stack
delftstack.com › home › howto › python pandas › pandas fillna multiple columns
How to Replace NA Values in Multiple Columns using Pandas fillna() | Delft Stack
February 2, 2024 - To fill the empty values within the City_Temp dataframe, we can use the fillna() function from Pandas within a print statement. In the fillna() function, we will add a single value of 80.0, and when the result is printed to the console, we will ...
🌐
Arab Psychology
scales.arabpsychology.com › home › stats › how to fill na values for multiple columns in pandas
How To Fill NA Values For Multiple Columns In Pandas
December 12, 2025 - When working with large datasets in Python, the Pandas library provides highly efficient tools for managing these gaps. Specifically, the fillna() function is the primary mechanism for imputing missing entries across a DataFrame. The versatility of the fillna() function allows data scientists to replace missing entries using various strategies, ranging from simple scalar replacements to sophisticated forward or backward propagation, or even statistical imputation based on column ...
Top answer
1 of 2
2

fillna is generally for carrying an observation forward or backward. Instead, I'd use np.where... If I understand what you're asking.

import numpy as np
np.where(np.isnan(df['newcolumn1']), df['oldcolumn1'], df['newcolumn1'])
2 of 2
0

To answer your question: yes. Look at using the value argument of fillna. Along with the to_dict() method on the other dataframe.

But to really solve your problem, have a look at the update() method of the DataFrame. Assuming your two dataframes are similarly indexed, I think it's exactly what you want.

In [36]: df = pd.DataFrame({'A': [0, np.nan, 2, 3, np.nan, 5], 'B': [1, 0, 1, np.nan, np.nan, 1]})

In [37]: df
Out[37]: 
    A   B
0   0   1
1 NaN   0
2   2   1
3   3 NaN
4 NaN NaN
5   5   1

In [38]: df2 = pd.DataFrame({'A': [0, np.nan, 2, 3, 4, 5], 'B': [1, 0, 1, 1, 0, 0]})

In [40]: df2
Out[40]: 
    A  B
0   0  1
1 NaN  0
2   2  1
3   3  1
4   4  0
5   5  0

In [52]: df.update(df2, overwrite=False)

In [53]: df
Out[53]: 
    A  B
0   0  1
1 NaN  0
2   2  1
3   3  1
4   4  0
5   5  1

Notice that all the NaNs in df were replaced except for (1, A) since that was also NaN in df2. Also some of the values like (5, B) differed between df and df2. By using overwrite=False it keeps the value from df.

EDIT: Based on comments it seems like your looking for a solution where the column names don't match over the two DataFrames (It'd be helpful if you posted sample data). Let's try that, replacing column A with C and B with D.

In [33]: df = pd.DataFrame({'A': [0, np.nan, 2, 3, np.nan, 5], 'B': [1, 0, 1, np.nan, np.nan, 1]})

In [34]: df2 = pd.DataFrame({'C': [0, np.nan, 2, 3, 4, 5], 'D': [1, 0, 1, 1, 0, 0]})

In [35]: df
Out[35]: 
    A   B
0   0   1
1 NaN   0
2   2   1
3   3 NaN
4 NaN NaN
5   5   1

In [36]: df2
Out[36]: 
    C  D
0   0  1
1 NaN  0
2   2  1
3   3  1
4   4  0
5   5  0

In [37]: d = {'A': df2.C, 'B': df2.D}  # pass this values in fillna

In [38]: df
Out[38]: 
    A   B
0   0   1
1 NaN   0
2   2   1
3   3 NaN
4 NaN NaN
5   5   1

In [40]: df.fillna(value=d)
Out[40]: 
    A  B
0   0  1
1 NaN  0
2   2  1
3   3  1
4   4  0
5   5  1

I think if you invest the time to learn pandas you'll hit fewer moments of frustration. It's a massive library though, so it takes time.

🌐
KDnuggets
kdnuggets.com › 2023 › 02 › optimal-way-input-missing-data-pandas-fillna.html
The Optimal Way to Input Missing Data with Pandas fillna() - KDnuggets
One thing to do with the missing data is to replace it with another value. To do that, we can use the Pandas function called fillna. Using the function is simple, but there are a few methods to optimally fill up our data, including replacing missing data in multiple columns, limiting the ...
🌐
GitHub
github.com › pandas-dev › pandas › issues › 27310
Fillna with inplace=True not working with multiple columns but fine with single column · Issue #27310 · pandas-dev/pandas
July 9, 2019 - You switched accounts on another tab or window. Reload to refresh your session. ... There was an error while loading. Please reload this page. ... import pandas as pd import numpy as np test = pd.DataFrame([[np.nan, 2, np.nan], [3, 4, np.nan], [np.nan, np.nan, 30], [np.nan, 3, 5]], columns=list('ABC')) # For multiple columns, `inplace=True` is not working. test[['A','B']].fillna('Missing',inplace=True) print(test) # For a single column,` inplace=True` works.
Author   thoo
Top answer
1 of 2
11

These answers are guided by the fact that OP wanted an in place edit of an existing dataframe. Usually, I overwrite the existing dataframe with a new one.


Use pandas.DataFrame.fillna with a dict

Pandas fillna allows us to pass a dictionary that specifies which columns will be filled in and with what.

So this will work

a.fillna({'a': 0, 'b': 0})

     a    b  c
0  1.0  5.0  5
1  2.0  0.0  1
2  0.0  6.0  5
3  0.0  0.0  2

With an in place edit made possible with:

a.fillna({'a': 0, 'b': 0}, inplace=True)

NOTE: I would've just done this a = a.fillna({'a': 0, 'b': 0})

We don't save text length but we could get cute using dict.fromkeys

a.fillna(dict.fromkeys(['a', 'b'], 0), inplace=True)

loc

We can use the same format as the OP but place it in the correct columns using loc

a.loc[:, ['a', 'b']] = a[['a', 'b']].fillna(0)

a

     a    b  c
0  1.0  5.0  5
1  2.0  0.0  1
2  0.0  6.0  5
3  0.0  0.0  2

pandas.DataFrame.update

Explicitly made to make in place edits with the non-null values of another dataframe

a.update(a[['a', 'b']].fillna(0))

a

     a    b  c
0  1.0  5.0  5
1  2.0  0.0  1
2  0.0  6.0  5
3  0.0  0.0  2

Iterate column by column

I really don't like this approach because it is unnecessarily verbose

for col in ['a', 'b']:
    a[col].fillna(0, inplace=True)

a

     a    b  c
0  1.0  5.0  5
1  2.0  0.0  1
2  0.0  6.0  5
3  0.0  0.0  2

fillna with a dataframe

Use the result of a[['a', 'b']].fillna(0) as the input for another fillna. In my opinion, this is silly. Just use the first option.

a.fillna(a[['a', 'b']].fillna(0), inplace=True)

a

     a    b  c
0  1.0  5.0  5
1  2.0  0.0  1
2  0.0  6.0  5
3  0.0  0.0  2
2 of 2
3

EDIT: As @piRSquared pointed out, the first solution should be

a.loc[:, ['a', 'b']] = a[['a', 'b']].fillna(0)

to fillna in selected columns

or

a.fillna(0, inplace = True)

to fillna in all the columns

🌐
Arab Psychology
scales.arabpsychology.com › home › pyspark: use fillna() with specific columns
PySpark: Use Fillna() With Specific Columns
November 17, 2025 - Instead, we can pass a Python list containing the names of all target columns to the subset parameter. This executes the imputation process simultaneously across all specified fields, maximizing performance and code cleanliness within the PySpark ...