I want to create a class that includes some functions, that one of them call another one in class, something like that:
import pandas as pd
class Prep:
def __init__(self, data):
self.data = data
def slicing(self):
sliceInput = self.data.iloc[:, 1:8]
sliceTarget = self.data.iloc[:, 8]
return sliceInput, sliceTarget
def convert(self):
convertInput = sliceInput.to_numpy(float)
convertTarget = sliceTarget.to_numpy(int)
return convertInput, convertTarget
if __name__ == "__main__":
data_frame = pd.read_csv('data_manual.csv', sep=';')
tes = Prep(data_frame)
print(tes.convert())
i got error like this
NameError: name 'sliceInput' is not defined
how to call convertInput and convertTarget in function
why I get an error, I don't understand at all.
self.sliceInput = self.data.iloc[:, 1:8]andself.sliceTarget = self.data.iloc[:, 8]will do the trick