0

so i have this func that creates a variable of a range and the name of the range itself.

for example: key: range(0,5) , val = '0-5'

due to reasons of dynamical allocation i want to send df.apply with the function and a calculated variable to use with.

how should i do it?

def appsgroup(a,length):
    apps_grouper = {}

for i in range(0,length,length//20):
    apps_grouper[range(i ,i+length//20)] = '{0}-{1}'.format(i,i+length//20)   
for key, val in apps_grouper.items():
    if a in key:
        return val

length= len(set(Grouped.apps.values))
Grouped['apps2'] = Grouped.apps.apply(appsgroup, length ?) 
Talis
  • 283
  • 3
  • 13
  • Possible duplicate of [python pandas: apply a function with arguments to a series](https://stackoverflow.com/questions/12182744/python-pandas-apply-a-function-with-arguments-to-a-series) – Keyur Potdar Feb 14 '19 at 17:11
  • 1
    `Grouped['apps2'] = Grouped.apps.apply(appsgroup, args=(length,)) ` – Keyur Potdar Feb 14 '19 at 17:12

0 Answers0