【发布时间】:2020-06-30 16:20:37
【问题描述】:
# Create a class DataExplore
class DataExplore:
# Define initialization method
def __init__(self, filepath):
self.filepath = filepath
self.data = pd.read_csv(filepath)
# Define desc_stats method, with argument
def desc_stats(self):
# Return a description data_as_csv
return self.data.describe()
def miss_values(self):
return self.data.isnull().sum().sum()
def fill_missing(self):
fill = self.data.interpolate(method='linear', axis=0).ffill().bfill()
return fill
def correl(self):
return self.data.corr(method = 'pearson')
### linear regression
def ln_reg(self):
self.data = self.data.interpolate(method='linear', axis=0).ffill().bfill()
x = self.data.iloc[:, 2:]
y = self.data.iloc[:,1]
model = sm.OLS(y, x).fit()
return model.summary()
## Passed the cvs file to the class DataExplore
data_explore = DataExplore('project_data.csv')
#print(data_explore.desc_stats())
#print (data_explore.correl())
#print(data_explore.miss_values())
#print(data_explore.fill_missing())
print(data_explore.ln_reg())
【问题讨论】:
-
您的示例中没有 tkinter 代码。 “进入 tkinter”是什么意思?
标签: python python-3.x tkinter tkinter-canvas