Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sum a dictionary of classes
#3
Ah yeah sorry, i can see that now. But let's put it like this. I have a chunk of data (a list of list) and i want to get the sum of certain columns (Mean and hit) sorted by keys (Team, League, Odds group):

The data:
Team League Odds group Mean Hit
Arsenal PL 1 0,4 0,5
Fulham PL 3 0,25 0,4
Aston Villa CL 2 0,55 0,6
Sunderland L1 1 0,43 0,5
Arsenal PL 1 0,3 0,4
Fulham PL 2 0,5 0,5
Aston Villa CL 1 0,4 0,5
Sunderland L1 1 0,4 0,6

The sum sorted by team
Sum by team Mean Hit
Arsenal 0,7 0,9
Fulham 0,75 0,9
Aston Villa 0,95 1,1
Sunderland 0,83 1,1

The sum sorted by league
Sum by league Mean Hit
PL 1,45 1,8
PL 1,45 1,8
CL 0,95 1,1

The sum sorted by odds group
Sum by odds group Mean Hit
1 1,93 2,5
2 1,05 1,1
3 0,25 0,4

Is there a clever way to accomplish this? Maybe use a dictionary or a class or something else?
Hope this makes the question more clear :)
Reply


Messages In This Thread
sum a dictionary of classes - by tobbs - Mar-15-2019, 04:54 PM
RE: sum a dictionary of classes - by Yoriz - Mar-15-2019, 05:28 PM
RE: sum a dictionary of classes - by tobbs - Mar-16-2019, 02:38 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Using classes? Can I just use classes to structure code? muteboy 5 5,066 Nov-01-2017, 04:20 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020