Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1090851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:26:01+00:00 2026-05-16T23:26:01+00:00

In Python, I have a list of dicts as follows: orig_list = [ {‘first_name’:

  • 0

In Python, I have a list of dicts as follows:

orig_list = [
{'first_name': u'Jake', 'last_name': u'Sarson', 'team': u'TeamOne', 
 'display_name': u'AVG', 'value': 7.0},

{'first_name': u'Mike', 'last_name': u'Walsh', 'team': u'TeamTwo', 
 'display_name': u'AVG', 'value': 12.0},

{'first_name': u'Jake', 'last_name': u'Sarson', 'team': u'TeamOne', 
 'display_name': u'AVG', 'value': 7.0},

{'first_name': u'Mike', 'last_name': u'Walsh', 'team': u'TeamTwo', 
 'display_name': u'AVG', 'value': 12.0},

{'first_name': u'Steve', 'last_name': u'Mottola', 'team': u'TeamTwo', 
 'display_name': u'AVG', 'value': 18.0},

{'first_name': u'Steve', 'last_name': u'Mottola', 'team': u'TeamTwo', 
 'display_name': u'AVG', 'value': 18.0},

{'first_name': u'Craig', 'last_name': u'Schubert', 'team': u'TeamOne', 
 'display_name': u'AVG', 'value': 23.5},

{'first_name': u'Steve', 'last_name': u'Mottola', 'team': u'TeamTwo', 
 'display_name': u'REC', 'value': 2.0},

{'first_name': u'Mike', 'last_name': u'Walsh', 'team': u'TeamTwo', 
 'display_name': u'REC', 'value': 1.0},

{'first_name': u'Jake', 'last_name': u'Sarson', 'team': u'TeamOne', 
 'display_name': u'REC', 'value': 1.0},

{'first_name': u'Craig', 'last_name': u'Schubert', 'team': u'TeamOne', 
 'display_name': u'REC', 'value': 2.0},

{'first_name': u'Craig', 'last_name': u'Schubert', 'team': u'TeamOne', 
 'display_name': u'TD', 'value': 1.0},

{'first_name': u'Steve', 'last_name': u'Mottola', 'team': u'TeamTwo', 
 'display_name': u'YDS', 'value': 36.0},

{'first_name': u'Jake', 'last_name': u'Sarson', 'team': u'TeamOne', 
 'display_name': u'YDS', 'value': 7.0},

{'first_name': u'Mike', 'last_name': u'Walsh', 'team': u'TeamTwo', 
 'display_name': u'YDS', 'value': 12.0},

{'first_name': u'Craig', 'last_name': u'Schubert', 'team': u'TeamOne', 
 'display_name': u'YDS', 'value': 47.0}]

I need to create a new list of dicts from the first list to find the unique names and for each name find all the display_name’s and the values. In essence the result should be:

[{'first_name': u'Jake', 'last_name': u'Sarson', 'team': u'TeamOne', 
  'AVG': 7.0, 'REC': 1.0, 'YDS': 7.0},
{'first_name': u'Mike', 'last_name': u'Walsh',  'team': u'TeamTwo',
  'AVG': 12.0, 'REC': 1.0, 'YDS': 12.0},
{'first_name': u'Steve', 'last_name': u'Mottola', 'team': u'TeamTwo',
  'AVG': 18.0, 'REC': 2.0, 'YDS': 36.0},
{'first_name': u'Craig', 'last_name': u'Schubert', 'team': u'TeamOne', 
  'AVG': 23.5, 'REC': 2.0, 'TD': 1.0, 'YDS': 47.0}]

I tried with nested for loops but kept getting an error that the “dict is unhashable.” What is the best solution for this data structure?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T23:26:02+00:00Added an answer on May 16, 2026 at 11:26 pm
    temp = {}
    for rec in orig_list:
        temp.setdefault((rec['first_name'], rec['last_name'], rec['team']), {}).setdefault(rec['display_name'], rec['value'])
    
    persons = []
    for key, person in temp.iteritems():
        person.update(dict(zip(('first_name', 'last_name', 'team'), key)))
        persons.append(person)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Python list, say l = [1,5,8] I want to write a
I have a list of Python objects that I want to sort by a
(code examples are python) Lets assume we have a list of percentages that add
I'm new to python, and have a list of longs which I want to
I have a list of dicts, something like this: test_data = [ { 'offset':0,
I have a list of dicts and I want to compare each dict in
I have a list of python dictionaries that look like this: sandwiches = [
I am new to python and I have a list of years and values
I have a Python list which holds pairs of key/value: l = [[1, 'A'],
I'm learning python. I have a list of simple entries and I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.