NumPy:基础统计

Python 入门

Hugo Bowne-Anderson

Data Scientist at DataCamp

数据分析

  • 了解您的数据

  • 小数据 -> 直接查看

  • 大数据 -> ?

Python 入门

全市调查

import numpy as np
np_city = ... # Implementation left out
np_city
array([[1.64, 71.78],
       [1.37, 63.35],
       [1.6 , 55.09],
       ...,
       [2.04, 74.85],
       [2.04, 68.72],
       [2.01, 73.57]])
Python 入门

NumPy

np.mean(np_city[:, 0])
1.7472
np.median(np_city[:, 0])
1.75
Python 入门

NumPy

np.corrcoef(np_city[:, 0], np_city[:, 1])
array([[ 1.     , -0.01802],
       [-0.01803,  1.     ]])
np.std(np_city[:, 0])
0.1992
  • sum()、sort() 等

  • 强制单一数据类型:更快!

Python 入门

生成数据

  • np.random.normal() 的参数
    • 分布均值
    • 分布标准差
    • 样本数
height = np.round(np.random.normal(1.75, 0.20, 5000), 2)

weight = np.round(np.random.normal(60.32, 15, 5000), 2)


np_city = np.column_stack((height, weight))
Python 入门

开始练习!

Python 入门

Preparing Video For Download...