Robin_hood_963
Robin_hood_963

Reputation: 65

Convert a list to dataframe with headers

I have a question I have a list

list=['nick', 'george', 'kate']

Is it possible to convert it into a dataframe with headers the names of the list ? ('nick' etc.) probably it's easy but I am a beginner so I struggle a little bit thanks!

Upvotes: 0

Views: 408

Answers (1)

Vinícius Félix
Vinícius Félix

Reputation: 8826

Code

import pandas as pd

list = ['nick', 'george', 'kate']

df = pd.DataFrame(list, columns =['name'])

print(df)

Output

     name
0    nick
1  george
2    kate 

Upvotes: 1

Related Questions