How to move each team row to a new column. Pandas - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: How to move each team row to a new column. Pandas (/thread-33955.html) |
How to move each team row to a new column. Pandas - vladiwnl - Jun-13-2021 Have a question how to move each team row to a new column dataset. So, I have 10 strings for 1 game and need to move this strings to columns to make dataframe look like this and for every stat. df = pd.DataFrame({'Team1':'[teamname]' , 'Team2':'[teamname]' , 'Score1': [0], 'Score2': [2],'team1_Player1_KD': [1], 'team1_Player2_KD': [2],'team1_Player3_KD': [1], 'team1_Player4_KD': [2],'team1_Player5_KD': [2], 'team2_Player1_KD': [2],'team2_Player2_KD': [1], 'team2_Player3_KD': [2],'team2_Player4_KD': [2], 'team2_Player5_KD': [2]})And my final dataset should look like 1 string per match with 200+ columns with player stats. But now have 25 columns for player and 5 string with player stat of 1 team and 2nd team. Have thoughts, its needed to make function that convert it, but Im new with python, so.. need help. [attachment=1136] I leave link to main dataframe. |