#numpy中arrary与pandas中series.DataFrame区别#arrary生成数组,无索引.列名:series有索引,且仅能创建一维数组:DataFrame有索引.列名import numpy as npimport pandas as pd #numpy基本用法print(np.array([1,2,3,"a"])) #创建并打印一维数组#a=np.array([1,2,3,"a"])#print(a.shape,a.size) #a.shape…
简单操作 Python-层次聚类-Hierarchical clustering >>> data = pd.Series(np.random.randn(10),index=[['a','a','a','b','b','c','c','d','d','d'],[1,2,3,1,2,1,2,3,1,2]]) >>> data a 1 -0.168871 2 0.828841 3 0.786215 b 1 0.506081 2 -2.304898 c 1 0.864875…
NumPy的ufuncs也可以操作pandas对象 >>> frame one two three four a 0 1 2 3 b 4 5 6 7 c 8 9 10 11 d 12 13 14 15 >>> np.square(frame)#求平方 one two three four a 0 1 4 9 b 16 25 36 49 c 64 81 100 121 d 144 169 196 225 >>> 用DataFrame的apply方法,可以…
今日内容概要 numpy剩余的知识点 pandas模块 今日内容详细 二元函数 加 add 减 sub 乘 mul 除 div 平方 power 数学统计方法 sum 求和 cumsum 累计求和 mean 对整体求平均数 std 标准差 var 方差 min max argmin 求最小元素对应的索引 armax 求最大元素对应的索引 随机数 np.random.rand(2.5) # 随机0-1之间的小数 array([[0.65863779, 0.9994306 , 0.35758039,…
一.Series的创建: pd.Series([ 数据 ]) In [17]: import pandas as pd In [18]: import numpy as np In [19]: s = pd.Series([1,1,1,1,np.nan]) In [20]: s Out[20]: 0 1.0 1 1.0 2 1.0 3 1.0 4 NaN dtype: float64 二.生成DataFrame 1,Numpy 产生随机数组 In [17]: np.random.rand(5,5…