'Can you add an attribute to an attribute in a class in python?
I would like to add an attribute to an existing attribute (or method if I need to). An example of this would be numpy's random method: numpy.random.rand()
In my case I have a matrix stored in the data attribute of my class: "myClass.data" that I would like to be able to easily call prespecified columns from: "Ex: myClass.data.columns"
class MyClass:
def __init__(self, data):
self.data = data
self.data.columns = self.data[1:3]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|