У меня есть большой фрейм данных с именем df
, который выглядит следующим образом:
First Name Last name Dept Location Status Concat
0 Jo Jones Accounts Bristol Current JonesJo
1 Sid Smith Sales Hull New SmithSid
2 Phil Evans Production Hull Current EvansPhil
3 Sarah Heath Marketing Bristol Current HeathSarah
4 Jane Hill Accounts Bristol Current HillJane
5 Amy Cooper Sales Hull Current CooperAmy
23453 Marcus Price Operations Hull Current PriceMarcus
23454 Andrew King Design Bristol Current KingAndrew
23455 Emma Lane Marketing Bristol Current LaneEmma
23456 Brian Deen Accounts Bristol Current DeenBrian
23457 Steve Jacks Design Bristol Current JacksSteve
Есть ли способ изменить значение поля в записи, если вы знаете «координаты» поля для изменения.
Например, я пытаюсь изменить значение 'Dept' Эми Купер с 'Sales' на 'Accounts', могу ли я сделать что-то вроде:
value = 'Accounts'
ConcatName = 'CooperAmy'
columnName = 'Dept'
df.ix[df['Concat']= ConcatName ,columnName ] = value
пь. Все значения Concat будут уникальными
Итак, мой результирующий фрейм данных будет выглядеть так:
First Name Last name Dept Location Status Concat
0 Jo Jones Accounts Bristol Current JonesJo
1 Sid Smith Sales Hull New SmithSid
2 Phil Evans Production Hull Current EvansPhil
3 Sarah Heath Marketing Bristol Current HeathSarah
4 Jane Hill Accounts Bristol Current HillJane
5 Amy Cooper Accounts Hull Current CooperAmy
23453 Marcus Price Operations Hull Current PriceMarcus
23454 Andrew King Design Bristol Current KingAndrew
23455 Emma Lane Marketing Bristol Current LaneEmma
23456 Brian Deen Accounts Bristol Current DeenBrian
23457 Steve Jacks Design Bristol Current JacksSteve