'Loop in pd.DataFrame(columns = X) where X is variable

So I've written a program that reads from a monthly released Excel file and converts it all into nice numpy arrays. In order to write this into an Excel file, I have to convert the numpy arrays back into DataFrames. The problem is that the "columns = " argument only takes in the names of each column, but every month, another month gets added on.

Any help is much appreciated. Code is:

fundsdf = pd.DataFrame(funds[1:], columns = ???)


Solution 1:[1]

The solution in my case was literally just to write columns = funds[0], so the code would be

fundsdf = pd.DataFrame(funds[1:], columns = funds[0])

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Henry Ecker