数据统计
数据采样,计算标准差,协方差和相关系数
1、简单的数据采样
df_inner.sample(n=3)
2、手动设置采样权重
weights = [0, 0, 0, 0, 0.5, 0.5]
df_inner.sample(n=2, weights=weights)
3、采样后不放回
df_inner.sample(n=6, replace=False)
4、采样后放回
df_inner.sample(n=6, replace=True)
5、 数据表描述性统计
df_inner.describe().round(2).T #round函数设置显示小数位,T表示转置
6、计算列的标准差
df_inner['price'].std()
7、计算两个字段间的协方差
df_inner['price'].cov(df_inner['m-point'])
8、数据表中所有字段间的协方差
df_inner.cov()
9、两个字段的相关性分析
df_inner['price'].corr(df_inner['m-point']) #相关系数在-1到1之间,接近1为正相关,接近-1为负相关,0为不相关
10、数据表的相关性分析
df_inner.corr()
数据输出
分析后的数据可以输出为xlsx格式和csv格式
1、写入Excel
df_inner.to_excel('excel_to_python.xlsx', sheet_name='bluewhale_cc')
2、写入到CSV
df_inner.to_csv('excel_to_python.csv')








暂无数据