# -*- coding: utf-8 -*-
"""
Created on Fri Jun 21 13:59:06 2019
@author: User
"""
# 《Python数据分析基础》中国统计出版社
import numpy as np
from scipy import stats
import pandas as pd
import statsmodels.api as sm
happiness = pd.read_csv(u'data\\ch6\\happiness.csv',encoding = "gbk")
print(happiness.head())
print(stats.ttest_rel(happiness['Year2015'],
happiness['Year2016']))
运行:
Ttest_relResult(statistic=-0.45945807951277384, pvalue=0.6464067663555169)