Re: pandas creating a new column based on row values

2017-03-28 Thread zljubisic
It works. Thank you very much. :) -- https://mail.python.org/mailman/listinfo/python-list

Re: pandas creating a new column based on row values

2017-03-28 Thread codewizard
On Tuesday, March 28, 2017 at 3:36:57 PM UTC-4, zlju...@gmail.com wrote: > [snip] > > Can I somehow generate a new column by concatenating values for the other > columns in a row? > Try this (not tested): def myfunc(row): return 'Start_{}_{}_{}_{}_End'.format(row['coverage'], row['name'],

pandas creating a new column based on row values

2017-03-28 Thread zljubisic
This doesn't work: import pandas as pd def myfunc(): return 'Start_{}_{}_{}_{}_End'.format(df['coverage'], df['name'], df['reports'], df['year']) data = {'name': ['Jason', 'Molly', 'Tina', 'Jake', 'Amy'], 'year': [2012, 2012, 2013, 2014, 2014], 'reports': [4, 24, 31, 2,