Post

PythonPython

j
jordan chris

Posted on 27th April 2024|19 views

0
votes

Pandas Dataframe Add Column

How can I add a new column in existing dataframe in pandas?

Answers
P
Surya kumar

Posted on 27th April 2024

You can do it by declaring a new list as a column

Import pandas as pd

data = { ‘name’ : [‘Mayuri’, ‘Prachi’],

  ‘marks’ : [35, 80] }

df = pd.DataFrame(data)

id = [123, 188]

df[id] = id

df

 

Write your answer

STILL GOT QUERIES?

Get a Live FREE Demo
  • Explore the trending and niche courses and learning maps
  • Learn about tuition fee, payment plans, and scholarships
  • Get access to webinars and self-paced learning videos