May-02-2020, 09:22 AM
x is instance of your class. it has instance attribute
alternative is your method to return what it reads
data
. you can work with x.data
as with any other name any way you like. I just print it, so that you can see it reads and data is accessible.alternative is your method to return what it reads
import pandas as pd import os class PythonTraining(): def read_data(self, filepath): base_path = "D:\Data" full_filepath = os.path.join(base_ath, filepath, "outsummary.csv") return pd.read_csv(full_filepath) x = PythonTraining() data = read_data("PythonCodes") print(data.head())
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs