luscgu00
luscgu00

Reputation: 43

Create Dataframe with a certain number of columns

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.

Upvotes: 1

Views: 83

Answers (1)

0x0fba
0x0fba

Reputation: 1620

for i in range(10):
    df[f"Power_{i}"] = df["Power"]

Upvotes: 1

Related Questions