I have a list of dataframes. Each dataframe within the list is unique - meaning that there are some shared, but different columns. I would like to create a single dataframe that contains all of the columns from the list of dataframes and will fill NaN if an element is not present. I have tried the following
import pandas as pd
df_new = pd.concat(list_of_dfs)
#I get the following: InvalidIndexError: Reindexing only valid with uniquely valued Index objects
Issue seem to be due to the dataframes in the list. Each data frame only has one row, so its index is zero and thus reindexing will not do the trick. I have tried this:
list_of_dfs.append(pd.DataFrame([rows], columns = tags).set_index(np.array(random.randint(0,5000))))
Pretty much generating a random number as the index. However, O get this error:
ValueError: The parameter "keys" may be a column key, one-dimensional array, or a list containing only valid column keys and one-dimensional arrays.