You can replace missing values in a pandas DataFrame with the values from the left by using the ffill()
method.
Here's an example of how to do it:
main.py255 chars12 lines
This will replace the missing values in each column with the previous non-null value from the left. The ffill()
method stands for "forward-fill".
Output:
main.py72 chars7 lines
In the above example, the missing values in column A and column B are replaced with the values from left.
gistlibby LogSnag