Home > front end >  Create a dataframe from a dictionary which is inside a tuple which is inside a list?
Create a dataframe from a dictionary which is inside a tuple which is inside a list?

Time:07-25

This is my final line of code , I need to create a python dataframe from the below line of code. This code is outputting the following see screenshot , How will I create a pandas dataframe from the below code ?

from pprint import pprint
query="Pepper"
results=search(query, top_k=2, index=index, model=model)
cutoff_list = []
number_list = []
print("\n")
for result in results:
    #print('\t',result)
    cutoff_list.append(result)
 
cutoff_list

Screenshotstrong text

I need the following output enter image description here

Please help

CodePudding user response:

data = []

for item in cutoff_list:
    tmp = {}
    for item2 in item:
        tmp.update(item2)
    data.append(tmp)


df = pd.DataFrame(data)
print(df)
  • Related