I have a list with some elements. For example: list= [name, phone_number,age,gender] I want to use these elements as a header or column name in a pandas dataframe.
I would really appreciate your ideas.
I have a list with some elements. For example: list= [name, phone_number,age,gender] I want to use these elements as a header or column name in a pandas dataframe.
I would really appreciate your ideas.
Assuming you put all the values that will be used as headers into an array using this code:
import pandas as pd
data = pd.read_csv("yourtable.csv")
i = 0
headers = []
while i < len(data. index):headers.append(data.loc[i, "header of headers"])i = i + 1
You can create your table using
df = pd.DataFrame(columns=headers)
EDIT:
With the new info just use:
df = pd.DataFrame(columns=list)