I'm new to pandas. I'm trying to add new columns to my existing DataFrame but It's not getting assigned don't know why can anyone explain me what I'm missing this is what i tried
import pandas as pd
df = pd.DataFrame(data = {"test":["mkt1","mkt2","mkt3"],
"test2":["cty1","cty2","cty3"]})
print("Before",df.columns)
df.assign(test3="Hello")
print("After",df.columns)
Output
Before Index(['test', 'test2'], dtype='object')
After Index(['test', 'test2'], dtype='object')
assigndoes not occurinplace.df = df.assign(test3="Hello")?df = df.assign(test3="Hello")check I've added in between two print functions where should place it can you provide a solution for itdf.assign(test3="Hello")todf = df.assign(test3="Hello")