I have a base table of values:
import pandas as pd
import numpy as np
test = pd.read_csv('mean_test.csv')
test.replace('n/a',np.nan)
test
value1 value2 value3
1 9 5
5 NaN 4
9 55 NaN
NaN 4 9
I want to work out an average of three values, ignoring NaN, so for the second line it will be (5 + 4) / 2. Therefore, I cannot use the .replace function to put a zero in the NaN place. I looked through some other questions, but cannot find anything to cover it. Am I missing something?
source
share