Perhaps this is not the right way to approach the class structure however, I was trying to store a dataset within __init__
ad then call them in another function to read the first few results from head
, however I do not get a dataframe output.
for example:
import faraway.datasets.pima
pima = faraway.datasets.pima.load()
#print(pima.head())
class automate_lm:
def __init__(self, data):
__dataset__ = data
def __print__(self):
__p__ = self.__dataset__.head()
return(__p__)
if __name__ == '__main__':
test=automate_lm(pima)
print(test.__print__)
Gives:
<bound method automate_lm.__print__ of <__main__.automate_lm object at 0x7fae1014b670>>
Expected output:
pregnant glucose diastolic triceps insulin bmi diabetes age test
0 6 148 72 35 0 33.6 0.627 50 1
1 1 85 66 29 0 26.6 0.351 31 0
2 8 183 64 0 0 23.3 0.672 32 1
3 1 89 66 23 94 28.1 0.167 21 0
4 0 137 40 35 168 43.1 2.288 33 1