Apparently this question has already been answered, and I still cannot find a solution from the precedent material. I appoligize...
I am trying to add the index of the dataframe to a list after the if statement. I think the code is pretty explanatory. But, it is storing the values of the column instead of the value of the index.
here is my code:
what['revenueSKU'] = round(what['Quantity'] * what['Unit_cost'])
what['value(in%)'] = round(((what['revenueSKU']/t)*100),10)
classifier = pd.concat([what['value(in%)'],what['SKU']], axis=1, join='outer')
classifier1 = classifier.sort_values(by='value(in%)',ascending= False)
classifier1 = classifier1.set_index('SKU',drop=True,inplace=False)
print(classifier1)
cumulative_percentage = classifier1.cumsum()
print(cumulative_percentage)
classa = []
classb = []
classc = []
for sku in cumulative_percentage['value(in%)']:
if sku < 80:
classa.append(sku)
elif 80 < sku <=90:
classb.append(sku)
else:
classc.append(sku)
print('classa =', classa)
print('classb =', classb)
print('classc =', classc)
would someone have a hint of what needs to be changed?
also, i am a python beginner and i feel like everything I write is very unefficient, if someone also have advice on how I could improve on that, I would be so happy. Any help would be really appreciated.