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 7000869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:43:42+00:00 2026-05-27T20:43:42+00:00

I have created a list of dictionary in a format as below: [{u’PLAN_A’: True,

  • 0

I have created a list of dictionary in a format as below:

[{u'PLAN_A': True, u'PLAN_B': True, u'PLAN_C': True, u'PLAN_D': True, 
  u'PLAN_E': True, u'PLAN_F': True, 'date': u'2011-08-01', u'PLAN_G': True}
 {u'PLAN_A': True, u'PLAN_B': True, u'PLAN_C': True, u'PLAN_D': True, 
  u'PLAN_E': True, u'PLAN_F': True, 'date': u'2011-08-01', u'PLAN_G': True}]

A little explanation here:

The list contains information to check whether information regarding the investment plans is already provided for a particular month, if information is available, it will be TRUE, if not it will be FALSE
– PLAN_A is the name of an investment plan, which means there are 7 of them here
– True/False refers to whether information is entered for that particular month

I want to create a HTML output using django like the one below:

DATE    PLAN_A  PLAN_B  PLAN_C
2010-01 TRUE    FALSE   TRUE
2010-02 TRUE    FALSE   TRUE
2010-03 TRUE    FALSE   FALSE

I don’t want to hard-code the column name (i.e. PLAN_A, PLAN_B, PLANC), as there maybe increasing number of plans in the future.

I think that will be a for-loop for creating <tr> and <td>. If I am working this as R, I will rearrange the column of the dataframe to the way I like (maybe I want PLAN_A to be at the third column, but not the first column), but having known that dictionary cannot be sorted, I don’t know how to arrange the keys inside, as you can see in my dataset, the date key is at the 7th column.

Can anyone help? Thanks.

  • 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-27T20:43:43+00:00Added an answer on May 27, 2026 at 8:43 pm

    Here’s some code that given a list in the above format (with the missing comma in the right place) produces something you can work with:

    bydate = []
    planNames = set()
    for d in data:
        ddict = {'date': d['date']}
        plans = d
        del plans['date']
        planNames = planNames.union(plans.keys())
        ddict['plans']=plans
        bydate.append(ddict)
    

    after that, ‘bydate’ is:

    [{'date': u'2011-08-01', 'plans': {u'PLAN_B': True, u'PLAN_C': True, u'PLAN_A': True, u'PLAN_F': True, u'PLAN_G': True, u'PLAN_D': True, u'PLAN_E': True}}, {'date': u'2011-08-22', 'plans': {u'PLAN_B': False, u'PLAN_C': True, u'PLAN_A': True, u'PLAN_F': False, u'PLAN_G': True, u'PLAN_D': True, u'PLAN_E': True}}]
    

    which you can sort by the date key. And ‘planNames’ is:

    set([u'PLAN_B', u'PLAN_C', u'PLAN_A', u'PLAN_F', u'PLAN_G', u'PLAN_D', u'PLAN_E'])
    

    which is a set (like a list, but unique elements) of all the plan names mentioned in the data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a list view that displays the names and dates of items
We have created a new List View Style that shows thumbnails from a picture
I have created a nested list with drag/drop functionality. My issue is that I
I have created a custom list as a feature in sharepoint. i need to
I have created a dynamic list picker script using Jquery 1.3 and PHP that
I have created an editor template for representing selecting from a dynamic dropdown list
I have created a discount in commerce server, and linked it with a list
I have created a project in Dashcode, inserted a List control, enabled a dynamic
I have created a unbound listbox. I have the box showing a list of
I'm trying to access list data using SSRS 2008. I have created an XML

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.