Issue
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
Solution
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)
Answered By - Lurima
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.