CONTEXT
I am trying to create a DataFrame and fill out columns in that DataFrame based on whether or not the inserted lists have those columns.
Example Data:
Name Height Hair Color Eye Color
Bob 72 Blonde Blue
George 64 Green
John Brown Brown
The columns in the DataFrame would contain all the variables I want recorded but if a person does not have information for each column I'd like to fill out what I can in the DataFrame.
Sample Data / Code
name = ['Name', 'Bob'] <----- Each element has the associated column name and the value in a list.
height = ['Height', '72'] <----- Possible to search for height[0] in columns and place height[1] in there?
eye_color = ['Eye Color', 'Brown']
person = [name, height, eye_color]
columns = ['Name', 'Height', 'Hair Color', 'Eye Color']
df = pd.DataFrame(person, columns = columns)
Expected Outcome
Name Height Hair Eye Color
Bob 72 Brown
PROBLEM
I want to be able to pass a person through and fill out a column based on the information that is there and leave any columns that aren't there blank. And append people to the DataFrame in the same fashion. Is this possible?
Please let me know if any additional details would help in answering this question!