Skip to content

Instantly share code, notes, and snippets.

Created January 17, 2018 00:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/101822913cd0c36e769330796ec5b56e to your computer and use it in GitHub Desktop.
Save anonymous/101822913cd0c36e769330796ec5b56e to your computer and use it in GitHub Desktop.
dfdata= [('cat01','t1', 50), ('cat01','t2',60) ,('cat01','t3',70),('cat02','t1', 60), ('cat02','t2', 80)]
df = pd.DataFrame.from_records(data=dfdata, columns=['cat','term','value'])
df
cat term value
0 cat01 t1 50
1 cat01 t2 60
2 cat01 t3 70
3 cat02 t1 60
4 cat02 t2 80
v = np.vectorize(mydata, otypes=[mydata])
v(df.term, df.value).tolist()
[entry(term='t1', val=50),
entry(term='t2', val=60),
entry(term='t3', val=70),
entry(term='t1', val=60),
entry(term='t2', val=80)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment