I would like to initialize a pandas dataframe with column titles and one row of data. I would then like to append rows of data onto the end of this dataframe as I iterate through a file that I am reading the data from.
Here is an example of what I am doing and the issue that I am running into:
titles = ['a','b','c','d']
data = ['1','2','3','4']
df = pd.DataFrame(data, columns=titles)
ValueError: Shape of passed values is (4, 1), indices imply (4, 4)
I know that this is because the data is being inserted as one column instead of one row. How can I make sure the data is inserted as a row?
What is the best way to append additional rows of data onto the end of this dataframe?
df = pd.DataFrame([data], columns=titles)