I'm a beginner with python, need some help with an assignment. I have a CSV spreadsheet that looks similar to the one below, values have been tweaked to make it easier to explain. Using the Pandas library at it significantly helps with this kind of data.
What it looks like currently on Excel:
Date A B C
1/1/2020 09:00 5 6 7
1/1/2020 09:30 5 2 4
1/1/2020 10:00 5 2 1
1/1/2020 10:30 4 3 2
1/1/2020 11:00 6 4 1
2/1/2020 09:00 7 7 7
2/1/2020 09:30 5 4 3
2/1/2020 10:00 5 5 4
2/1/2020 10:30 5 6 6
2/1/2020 11:00 4 3 6
Expected output:
Date A B C D
1/1/2020 09:00 5 6 7
1/1/2020 09:30 5 2 4
1/1/2020 10:00 5 2 1
1/1/2020 10:30 4 3 2
1/1/2020 11:00 6 4 1
2/1/2020 09:00 7 7 7 6
2/1/2020 09:30 5 4 3 6
2/1/2020 10:00 5 5 4 6
2/1/2020 10:30 5 6 6 6
2/1/2020 11:00 4 3 6 6
D = A+B+C/3
but it uses the first or last ABC value of the day, been racking my brain trying to figure out how to set up the code to export to the Excel sheet.
I've tried multiple codes such as nth
, first
, groupby
but I'm not sure how to extract ABC from the day and create a new column to show D.
I think loc
could be used but it's a little confusing as I haven't been coding for long. Current code is garbage and doesn't do anything, so I'm not sure it's even worth showing here.
Any help would be appreciated, learning python is pretty fun but a little confusing without any guidance. Thanks.