Question: ```
dfs=[]

for i in range(387):
    print(i)
    dfs.append(pd.DataFrame(0, index=range(121211), columns=range(31)))

pd.concat(dfs,axis=1) #can only change this

```

In the code above, `pd.concat` is pretty slow, is there a way to make column join faster? assume I can only change the `pd.concat` part.

Answer: 
You are instantiating a very large dataframe all containing zero values. Rather than concatenate, just use the dataframe constructor with your desired index and columns.

```
dfs = pd.DataFrame(
    0, 
    index=range(121211), 
    columns=list(range(31)) * 387
)

```

For example (using a much smaller size dataframe):

```
>>> pd.DataFrame(0, index=range(3), columns=list(range(2)) * 3)
   0  1  0  1  0  1
0  0  0  0  0  0  0
1  0  0  0  0  0  0
2  0  0  0  0  0  0

```

**EDIT** 

Assuming that each dataframe has the same index, different columns and different values, try concatenating the numpy values directly (avoiding the overhead of index and column checking for `concat`).

```
pd.DataFrame(
    np.concatenate([df.values for df in dfs], axis=1),   
    index=dfs[0].index, 
    columns=[col for df in dfs for col in df]
)

```

After checking the timings of this approach vs. concat, they are very similar when using random data. For dataframes this large, you may want to consider alternative solutions such as [Dask](https://dask.org/).
It seems that `generator` and `transposing` do the work faster.

Beware that this code is RAM-hungry, so it is better to run both version separately.

```
import pandas as pd
import timeit

dfs=[]

for i in range(387):
    print(i)
    dfs.append(pd.DataFrame(0, index=range(121211), columns=range(31)))

#original
start = timeit.timeit()
fin1 = pd.concat(dfs, axis=1) 
print((timeit.timeit() - start) * 1000)
print(fin1.shape)
#0.7748472388211941
#(121211, 11997)

#faster
start = timeit.timeit()
fin2 = pd.concat((df.T for df in dfs), axis=0).T
print((timeit.timeit() - start) * 1000)
print(fin2.shape)
#0.09283745513703756
#(121211, 11997)

```