Open hayd opened 11 years ago
this is pretty straightforward after merging in series subclass NDFrame. This has to deal with possible dtype changes when doing column wise (which I think its not-implemented)
Came up again at SO
@jreback @jorisvandenbossche is this implemented yet? I was trying to do this result.fillna(result.mean(axis=1), axis =1 ) and got the same exception
issue is open
my simple/crude workaround below. curious why this issue is still open in 2018.
colnames = list(df)
for colname in colnames: df[colname].fillna(method='bfill', inplace=True)
curious why this issue is still open in 2018.
Because nobody made the effort to implement it. But you are welcome to do so.
Faced the same issue. It is worth mentioning here, @hayd solution posted in StackOverflow
Thanks for the workaround Andy!
This isn't implemented even in the latest version of pandas (v2.0.1). Can we reopen this issue, please?
To confirm, in my usage ffill(axis=1, inplace=True)
works as long as all dtypes of the columns are the same; I get NotImplemented
error if they have mixed dtypes.
I see this is still an open issue Not sure if I will be able to implement this, but assigning to myself to build on top of previous PR attempts.
take
Solution/workaround is to do transpose?
We actually used transpose (i.e., df.T.fillna(df.mean(1)).T
), but it proved to be really horrendous with regard to performance. This performance issue happens especially when the index of df
is (much) longer than the number of columns. We solved it by using apply instead:
df_mean = df.mean(1)
df.apply(lambda col: col.fillna(df_mean))
As per discussion on this SO question is NotImplementedError.
Solution/workaround is to transpose do transpose? This is used elsewhere in DataFrame.fillna method. just raise if inplace?
cc @cpcloud