In this dataframe i want that level gets automatically selected from segment column and perform rest operation. I tried this but in this i need to change level every time. How to automate it?
yy = pd.DataFrame({'segment':['High','High', 'premium','local','local','local'],'value':[12,'NAN',13,'NAN',14,15]})
level='High'
def seg(temp):
**temp1 = yy[yy['segment'] == level]**
temp2= temp1.replace("NAN", 0)
return temp2
seg(yy)