self
in the class is the instance itself. If you want to use a instance attribute inside the class you need to use it with self.class PythonTraining(): def read_data(self, filepath): base_path = "D:\Data" full_filepath = os.path.join(base_path, filepath, "outsummary2.csv") self.data = pd.read_csv(full_filepath) def cal_rowmean(self, v1): self.xmean = self.data['s3'].mean() + v1 print(self.xmean)Note, that read_data doesn't need to return self.data.
Also, note that you need to call read_data() before you call cal_rowmean or you will get AttributeError. It may be better if you refactor your class and move what reading data in class __init__ method (you don't have defined one now)
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