Create Dataframe with a certain number of columns

Question:

I have the following Dataframe:

Excert Dataframe

Now i want to copy the column "Power" as often as i want to another column in the same Dataframe.
The column names should be: Power_1; Power_2; Power_3…..

Creating the Dataframe is too complicated to share, but a simple example how to add the columns with a while-loop would be sufficient.

Asked By: luscgu00

||

Answers:

for i in range(10):
    df[f"Power_{i}"] = df["Power"]
Answered By: 0x0fba
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.