Q:

Skip nan and shift elements in a pandas dataframe row

I have a dataframe like this [![Dataframe looks like this][1]: https://i.stack.imgur.com/R7GmM.png
Now I want to skip nan's and so that data shift towards left i.e. [![formatted dataframe should be like this] [1]: https://i.stack.imgur.com/yGYIy.png 
I am not able to do it via pandas. Is a scalable solution possible for this if I have a large dataset of let say 100k rows?
[EDIT]: Here is the data and desired output:
#Original df
>>> df
   A    B    C    D
0  a  NaN    c  NaN
1  b  NaN    b    a
2  c  NaN  NaN    d
3  d    a    b    c

#Desired output:

   A  B  C  D
0  a  c      
1  b  b  a   
2  c  d      
3  d  a  b  c

A:

Here is one method:
Starting from your dataframe named df:
   A    B    C    D
0  a  NaN    c  NaN
1  b  NaN    b    a
2  c  NaN  NaN    d
3  d    a    b    c

apply these line:
shifted_df = df.apply(lambda x: pd.Series(x.dropna().values), axis=1).fillna('')
shifted_df.columns = df.columns

And you get your resulting shifted_df dataframe:
>>> shifted_df
   A  B  C  D
0  a  c      
1  b  b  a   
2  c  d      
3  d  a  b  c

