For example, I have a dataframe which looks like this:
The wanted result is:
What should I do with pandas?
For example, I have a dataframe which looks like this:
The wanted result is:
What should I do with pandas?
Use a combination of dropna
and fillna
:
df=df.dropna(subset=['age']).fillna({'champions':1})
or, if you want to fill the values from the previous rows, use ffill
:
df=df.dropna(subset=['age']).ffill()