Input: +-----------------+----------+-------+| name | quantity | price |+-----------------+----------+-------+| Wristwatch | None |135|| WirelessEarbuds | None |821|| GolfClubs |779|9319|| Printer |849|3051|+-----------------+----------+-------+Output: +-----------------+----------+-------+| name | quantity | price |+-----------------+----------+-------+| Wristwatch |0|135|| WirelessEarbuds |0|821|| GolfClubs |779|9319|| Printer |849|3051|+-----------------+----------+-------+Explanation:
The quantity for Wristwatch and WirelessEarbuds are filled by 0.## Solution
### Method 1โ Pandas fillna
#### Intuition
We can use the `fillna` method in pandas to replace missing values(NaN)in the `quantity` column with0. This is a direct and efficient way to handle missing data in a DataFrame.#### Approach
1. Use the `fillna` method on the `quantity` column to replace NaN with0.2. Return the updated DataFrame.#### Code
1
-- Not applicable for this problem as it is a pandas/DataFrame problem.
1
-- Not applicable for this problem as it is a pandas/DataFrame problem.
#### Complexity
-โฐ Time complexity:ย `O(n)`, where n is the number of rows in the DataFrame, as each value in the column is checked once.-๐งบ Space complexity:ย `O(1)`, as the operation is done in-place (except for the returned DataFrame reference).