You can select your desired columns and do it by assignment:
df[['a', 'b']] = df[['a','b']].fillna(value=0)
The resulting output is as expected:
a b c
0 1.0 4.0 NaN
1 2.0 5.0 NaN
2 3.0 0.0 7.0
3 0.0 6.0 8.0
More Related Contents:
- How do I select rows from a DataFrame based on column values?
- Aggregation in Pandas
- Compare two DataFrames and output their differences side-by-side
- Constructing pandas DataFrame from values in variables gives “ValueError: If using all scalar values, you must pass an index”
- Can pandas automatically read dates from a CSV file?
- Selecting a row of pandas series/dataframe by integer index
- How do I find the closest values in a Pandas series to an input number?
- How do I count the NaN values in a column in pandas DataFrame?
- SQL-like window functions in PANDAS: Row Numbering in Python Pandas Dataframe
- Get column index from column name in python pandas
- Replace invalid values with None in Pandas DataFrame
- How to filter a dataframe of dates by a particular month/day?
- How to show all columns’ names on a large pandas dataframe?
- Count number of words per row
- Shift column in pandas dataframe up by one?
- pandas DataFrame output end of csv
- Pandas get frequency of item occurrences in a column as percentage [duplicate]
- Pandas compare next row
- Appending a list or series to a pandas DataFrame as a row?
- Convert Pandas Series to DateTime in a DataFrame
- Loading multiple csv files of a folder into one dataframe
- Why is np.where faster than pd.apply
- Extract column value based on another column in Pandas
- Python Pandas: Get index of rows where column matches certain value
- Change the color of text within a pandas dataframe html table python using styles and css
- Row-wise average for a subset of columns with missing values
- Plot multiple columns of pandas DataFrame using Seaborn
- Dynamically filtering a pandas dataframe
- Remove substring from column based on another column
- How to get number of groups in a groupby object in pandas?