I have the following dataframe:
col1 col2
basic c
c c++
c++ java
ruby
php
java python
python
r
c#
I want to create new columns based on a pattern followed in dataframe.
For example, in the above dataframe basic->c->c++->java->python order can be observed from col1 and col2.
Logic:
col1 value basic has c value in col2, similarly c value in col1 corresponds to c++ in col2, c++ leads to java in col2 and finally java to python in col2.
Remaining values in "col1" which have corresponding blanks in col2 would be left blank in newly created columns as well. (that is, we consider only the values in "col1" which do not have blanks in col2).
So my output dataframe would be:
col1 col2 new_col1 new_col2 new_col3 new_col4
0 basic c c c++ java python
1 c c++ c++ java python
2 c++ java java python
3 ruby
4 php
5 java python python
6 python
7 r
8 c
Thanks !
