0

I have a CSV file as below:

  • name
  • john
  • eve

And a list: state=['India','US']

I want to add new column to the existing csv file with the list items as data to that column

What I want:

  • name - state
  • john - India
  • eve - Us

1 Answers1

0

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

code example:

import pandas as pd

data = {'name': ['john', 'eve']}
df = pd.DataFrame(data)

state = ['India','US']
df['state'] = state

print(df)
Lurima
  • 52
  • 3