May-02-2020, 09:49 AM
That's fine, one more thing, I want to pass this variable to another, I use the below code, but it gives an error that data is undefined. how we pass variables to one instance to another.
I calculate mean of column "s3" in data. "self.xmean = data['s3'].mean() + v1"
I calculate mean of column "s3" in data. "self.xmean = data['s3'].mean() + v1"
import pandas as pd import os 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) return self.data def cal_rowmean(self, v1): self.xmean = data['s3'].mean() + v1 print(self.xmean) x = PythonTraining() x.read_data("PythonCodes") x.cal_rowmean(10) print(x.data.head())