The “fillna” function in Pandas not only can replace missing values with a given constant value, like in this example:
import pandas as pd
import numpy as np
df = pd.DataFrame([[np.nan], [2], [np.nan], [0]])
df
A dataframe with missing values
df.fillna(47)
Missing values replaced with a constant
You can also replace a missing value with the next (or previous) value in the data frame!
df.fillna(method = "ffill")
Missing values filled with the previous existing value.
Note that the first value cannot be replaced because nothing is preceding it.
You can also use the value of the next row to fill a missing value.
df.fillna(method = "bfill")
Missing values filled with the next existing value.
Clicking the newsletter button opens a separate page hosted by ActiveCampaign with a Google Captcha. You will get their cookies.
It has to be a separate page because many spam bots subscribed recently, so I must filter them out using a Captcha. Unfortunately, Captcha requires cookies, and I don't want any cookies (especially third-party cookies) used on this page.