I have a dataset like below:
Group Attributes S2SFlag
Age 1 to 5 Yes
Age 6 to 10 No
Channel DD No
Channel Agency Yes
Status Lapse Yes
Status Active Yes
Now I want to explode the values of the 'Age' group by the range defined in the attributes column while retaining other column values.
The expected output is as below:
Attempt so far:
df1 = pd.read_csv('')
df1 = df1[df1['Group'] == 'Age']
attrList = df1['Attributes'].tolist()
for i in attrList:
start = i.split(" to ")[0]
end = i.split(" to ")[1]
for j in range(int(start), int(end) + 1):
df1['Attributes'] = str(j)
It is giving me output as below:
Group Attributes S2SFlag
0 Age 10 Yes
1 Age 10 No
