DEV Community

Nilotpal Choudhury
Nilotpal Choudhury

Posted on

1

Answer: Add values to an existing dataframe from list of tuples

You can use double [] with columns names, join or concat:

df = pd.DataFrame({'column':range(5)})
print (df)
   column
0       0
1       1
2       2
3       3
4       4

l = [('l1', 0.966797), ('l1', 0.998047), 
     ('l2', 0.978516), ('l2', 0.998047), ('l3', 0.972656)]

df[['s','p']] = pd.DataFrame(l)

df = df.join(pd.DataFrame(l,columns=['s','p']))

df = pd.concat([df, pd.DataFrame(l,columns=['s','p'])],

Top comments (0)

Hosting.com image

Your VPS. Your rules.

No bloat, no shortcuts. Just raw VPS power with full root, NVMe storage, and AMD EPYC performance. Ready when you are.

Learn more

👋 Kindness is contagious

Explore this practical breakdown on DEV’s open platform, where developers from every background come together to push boundaries. No matter your experience, your viewpoint enriches the conversation.

Dropping a simple “thank you” or question in the comments goes a long way in supporting authors—your feedback helps ideas evolve.

At DEV, shared discovery drives progress and builds lasting bonds. If this post resonated, a quick nod of appreciation can make all the difference.

Okay