numpy处理身高例子

数据如下(姓名, 身高)

order,name,height(cm)
1,George Washington,189
2,John Adams,170
3,Thomas Jefferson,189
4,a,160
5,b,190
6,c,189
7,d,183
8,e,170
9,f,178
10,g,185
11,g1,175
12,g2,150
#coding:utf-8
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

if __name__ == '__main__':
    x = np.arange(10)
    '''
    #numpy基本函数
    print sum(x)
    print np.sum(x)
    print max(x)
    print min(x)
    print np.max(x)
    x = np.array([[1,2,3],[4,5,6]])
    print x
    print x.sum(axis=1) #横向加
    print x.sum(axis=0) #纵向
    '''

    #案列
    data = pd.read_csv('data.csv')
    h = data['height(cm)'] #获取身高
    print h
    print h.max()
    print h.mean()
    print h.std()#标准差
    print np.median(h) #中位数
    #绘图
    plt.title("height")
    plt.xlabel("height(cm)")
    plt.ylabel("number")
    print type(h)
    plt.hist(h)
    plt.show()

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容