Convert list of dictionaries to a pandas DataFrame

前端 未结 7 2218
清酒与你
清酒与你 2020-11-22 01:22

I have a list of dictionaries like this:

[{\'points\': 50, \'time\': \'5:00\', \'year\': 2010}, 
{\'points\': 25, \'time\': \'6:00\', \'month\': \"february\"         


        
相关标签:
7条回答
  • 2020-11-22 01:47

    For converting a list of dictionaries to a pandas DataFrame, you can use "append":

    We have a dictionary called dic and dic has 30 list items (list1, list2,…, list30)

    1. step1: define a variable for keeping your result (ex: total_df)
    2. step2: initialize total_df with list1
    3. step3: use "for loop" for append all lists to total_df
    total_df=list1
    nums=Series(np.arange(start=2, stop=31))
    for num in nums:
        total_df=total_df.append(dic['list'+str(num)])
    
    0 讨论(0)
提交回复
热议问题