I would like to populate a pandas dataframe from attributes of a list of classes generated via 'append'. (not sure this is the right term to describe 'allFoo' below Here is a stripped down example code:
class foo(object):
def __init__(self,input):
self.val=input
#in real life, there will be many more attributes in this class
allFoo=[];
for i in range(10):
allFoo.append(foo(i))
now I would like to define a new pandas data frame 'df' that gets populated from allFoo.val (and not any other attributes)
something like this:
df[0]=foo[0].val
df[1]=foo[1].val
etc
I am coming from matlab where I would try something like this: dataFrame=allFoo[:].val
how can I achieve this in python/pandas?
dataFrame['val'] = allFoo
should work