Hi There,
I am new to python so please be kind to me.
Below is the data frame and the requirement:
I am new to python so please be kind to me.
Below is the data frame and the requirement:
data = {'id': ['aa11bc', 'bb22cd', 'cc33ef', 'dd44gh', 'ee55ij','ff66kl','gg77mn','hh88op'],
'direction': ["north, south, east, west", "north, south, east, west", "north, south, east, west", "north, south, east, west",
"north, south, east, west","north, south, east, west","north, south, east, west"
,"north, south, east, west"]}
df = pd.DataFrame(data, columns = ['id','direction'])
df
Requirement:
#if id (2nd and 3rd letter) in ('a1','b2') then new_col should have north as an observation from direction column
#else if id (2nd and 3rd letter) in ('c3','d4') then new_col should have south as an observation from direction column
#else if id (2nd and 3rd letter) in ('e5','f6') then new_col should have east as an observation from direction column
#else if id (2nd and 3rd letter) in ('g7','h8') then new_col should have west as an observation from direction columnAppreciate if you guys can assist me with this.
