I tried to modify the dataframe through function and return the modified dataframe. Somehow, it is not reflected. In the below code, I pass a dataframe 'ding' to function 'test' and create a new column 'C' and return the modified dataframe. I expected the test_ding df to have 3 columns but could see only two columns. Any help is highly appreciated.
s1 = pd.Series([1,3,5,6,8,10,1,1,1,1,1,1])
s2 = pd.Series([4,5,6,8,10,1,7,1,6,5,4,3])
ding=pd.DataFrame({'A':s1,'B':s2})
def test(ding):
ding.C=ding.A+ding.B
return ding
test_ding=test(ding)