gberdou
gberdou

Reputation: 25

Exclude column from calculation and then retrieve it again

I have a df (ndv19) with n number of columns. I need to exclude column named 'Id'(position = 1) from a calculation I need to perform (other columns names are dates such as 20161025), and once calculation is done, retrieve again the previously excluded column 'Id' respecting its former position. I tried with iloc and drop, I succeed to exclude, but I dont know how to retrieve afterwards... Thanks in advance!!

succeded to exclude with this = rep19.ix[:,~rep19.columns.str.contains('^I')] and this rep19.iloc[:,1:,]

Upvotes: 1

Views: 650

Answers (1)

MBA Coder
MBA Coder

Reputation: 384

Try this

temp_df = ndv19['Id']
ndv19 = ndv19.drop(['Id'], axis=1)
# Do the calculations
ndv19['Id'] = temp_df

Upvotes: 1

Related Questions