I would like to relocate columns by condition. In case country is 'Japan', I need to relocate last_name and first_name reverse.
df = pd.DataFrame([['France','Kylian', 'Mbappe'],['Japan','Hiroyuki', 'Tajima'],['Japan','Shiji', 'Kagawa'],['England','Harry', 'Kane'],['Japan','Yuya', 'Ohsako'],['Portuguese','Cristiano', 'Ronaldo']],columns=['country', 'first_name', 'last_name'])
Current output is
country first_name last_name
0 France Kylian Mbappe
1 Japan Hiroyuki Tajima
2 Japan Shiji kagawa
3 England Harry Kane
4 Japan Yuya Ohsako
5 Portuguese Cristiano Ronaldo
I would like to make it following.
country first_name last_name
0 France Kylian Mbappe
1 Japan Tajima Hiroyuki
2 Japan Kagawa Shinji
3 England Harry Kane
4 Japan Ohsako Yuya
5 Portuguese Cristiano Ronaldo
Any idea?