Home > Software design >  Create Dataframe with a certain number of columns
Create Dataframe with a certain number of columns

Time:11-10

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.

CodePudding user response:

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