Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to transform pandas table
from functools import reduce
mylist1 = data[['category', 'frequency']].values
mylist2 = reduce(lambda x,y: x+y, [reduce(lambda x,y: [x]*y, l) for l in mylist1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment