I am trying to concatenate all columns of a pandas dataframe so that I end up with 1 column that contains all the values from the dataframe. The following code does this:
df2 = pd.concat([df[0], df[1], df[2], df[3], df[4], df[5], df[6], df[7]])
But I would like to be able to do this with dataframes that have different numbers of columns. When I tried:
dfpr2 = pd.concat([df.columns)
I get the following error:
"cannot concatenate object of type <class 'pandas.core.indexes.range.RangeIndex>; only Series and DataFrame objs are valid
is there a way to get around this? I tried setting ignore_index = True, but that did not seem to help either. Thanks!!