0

I'm new to the world of Python programming, I mainly work in BI Tools and Excel.

I have data that I need to reshape the data in something similar to a union. I want to use Python to do this do the next time new data comes in can do the task quickly.

In the attached image you'll see this is so the Home Teams and Away Teams can be filtered in one new column called Teams. Similarly, Home and Away Goals can to be filtered into one column called Goals.

I have the data loaded as a dataframe, I now need to reshape it. I'd really appreciate if I could be pointed in the right direction.

Thanks!

The Before and After

  • can you post your data as text? just copy each table, paste it in and click format as code. – Umar.H Oct 29 '20 at 09:52
  • 1
    `Date Time HomeTeam AwayTeam Home Goals Away Goals 12/09/2020 12:30 Fulham Arsenal 0 3 12/09/2020 15:00 Crystal Palace Southampton 1 0 12/09/2020 17:30 Liverpool Leeds 4 3 12/09/2020 20:00 West Ham Newcastle 0 2 13/09/2020 14:00 West Brom Leicester 0 3 13/09/2020 16:30 Tottenham Everton 0 1 14/09/2020 20:15 Brighton Chelsea 1 3 14/09/2020 18:00 Sheffield United Wolves 0 2 19/09/2020 12:30 Everton West Brom 5 2 19/09/2020 15:00 Leeds Fulham 4 3 19/09/2020 17:30 Man United Crystal Palace 1 3 19/09/2020 20:00 Arsenal West Ham 2 1 27/09/2020 14:00 Tottenham Newcastle 1 1` – JosephQuail Oct 29 '20 at 09:57
  • Thanks for the reply, the above is a sample of the "Before Data". – JosephQuail Oct 29 '20 at 09:58
  • you should add it to your main body - i think the duplicate answers yur question but in future you need to make your question as reproducible as possible - you were close have a read of this question https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples – Umar.H Oct 29 '20 at 10:01
  • 1
    Thanks Manakin, the above answer to the question similar to mine worked. – JosephQuail Oct 29 '20 at 10:17

0 Answers0