In: Computer Science
A column in your data is missing a value in one row. Which command fills this missing data point with the value before it?
Select an answer:
df.fillna(method='bfill')
df.fillna(0)
df.fillna(method='linear')
df.fillna(method='ffill')
Ans: df.fillna(method='ffill')
--> ffill method replaces the missing values with the values before it.
-->If you see the below example, the NaN values are replaced with the values that are present before the missing value in the each column
--> and bfill method replaces the missing values with the values after it
-->If you see below example, the missing values are replaced by the values after it
-->fillna(0) replaces all the missing values with zero
Hope you like it, if you have any doubts please let me know in the comments, thank you.