I was given data formatted in a weird fashion
df = pd.DataFrame([[1, 2, None, None], [1, None, 4, None], [1, None, None, 9, None], [1, None, None, None, 4]])
df.columns = ['name', 'c1', 'c2', 'c3', 'c4']
name c1 c2 c3 c4
1 2.0 NaN NaN NaN
1 NaN 4.0 NaN NaN
1 NaN NaN 9.0 NaN
1 NaN NaN NaN 4.0
2 1.0 NaN NaN NaN
2 NaN 4.0 NaN NaN
Given the key "name", I want to basically fill the NaN values in the first row of a key with the first other non-NaN value and condense it to one row, like this.
name c1 c2 c3 c4
1 2.0 4.0 9.0 4.0
2 1.0 4.0 NaN NaN
What's the best function to accomplish this? A groupby with first() to grab the first non-NA value?