Фон
У меня есть следующий код
import pandas as pd
#create df
df = pd.DataFrame({'Before' : ['there are many different',
'i like a lot of sports ',
'the middle east has many '],
'After' : ['in the bright blue box',
'because they go really fast ',
'to ride and have fun '],
'P_ID': [1,2,3],
'Word' : ['crayons', 'cars', 'camels'],
'N_ID' : ['A1', 'A2', 'A3']
})
#rearrange
df = df[['P_ID', 'N_ID', 'Before', 'Word','After']]
, который создает следующие значения: df
P_ID N_ID Before Words After
0 1 A1 there are many different crayons in the bright blue box
1 2 A2 i like a lot of sports cars because they go really fast
2 3 A3 the middle east has many camels to ride and have fun
Цели
1) Соедините слова в столбцах Before
и After
со словами в столбце Word
2) Создайте new_column
Требуемый вывод
A new_column
со следующим выводом
new_column
there are many different crayons in the bright blue box
i like a lot of sports cars because they go really fast
the middle east has many camels to ride and have fun
Вопрос
Как мне выполнить мойцель