I have a class Asset
that takes a name (should be entered with quotation marks).
This will work fine: Apple = Asset ('AAPL')
I want to turn all dataframe columns into Asset objects. Am trying the following code but does not work:
for column in df.columns:
column = Asset (column)
I also tried the same thing with df.columns converted into a list of strings.
Edit My goal is to create one object for each column bearing the same name as the column. In this way, the object will possess the content of the column such as price automatically. The class is defined as:
class Asset:
def __init__(self, name):
self.name = name
self.price = df[name]
self.pct = self.price.pct_change()