Home > Mobile >  creation of new column
creation of new column

Time:12-09

Hellooo

I want to create a new column (D) that includes calculations from previous columns (A,B,C).

enter image description here

How could I do that?

CodePudding user response:

You can use assign() method in Pandas to create a new column D.

Example:

df = df.assign(D=df["A"]   df["B"]   df["C"])

CodePudding user response:

Just do so directly

df["D"] = df["A"]   df["B"]   df["C"] 
  • Related