# -*- coding: utf-8 -*-
"""created on sat jun 1 15:28:56 2019
@author: user
"""import pandas as pd
import numpy as np
from scipy import stats
stock=np.dtype([('id',np.str,5),
('time',np.str,10),
('code',np.str,10),
('open_p',np.float64),
('close_p',np.float64),
('low_p',np.float64),
('vol',np.int32),
('high_p',np.float64),
('col',np.int32)])
print('\n jd_stock:')
jd_stock=np.loadtxt('data\stock.csv',delimiter=',',dtype=stock)
print(jd_stock)
print('\n jddf:')
jddf=pd.read_csv('data\stock.csv',sep=',',header=none,
names=['id','time','code','open_p','colse_p','low_p','vol','high_p','col'])
print(jddf.head())
#print("\n :")
#print(jddf['open_p'].skew())
print("以上是資料準備----------------------------")
print("\n 各種變數的簡單統計描述 jddf.describe():")
print(jddf.describe())
print("\n 用 scipy 進行各種變數的簡單統計描述:")
print(stats.describe(jddf[['open_p','colse_p']]))
輸出:
jd_stock:
[('1', '20130902', '600028', 4.41, 4.43, 4.37, 17275, 4.41, 392662)
('2', '20130903', '600028', 4.41, 4.46, 4.4 , 19241, 4.45, 434177)
('3', '20130904', '600028', 4.44, 4.49, 4.42, 20106, 4.47, 451470) ...
('1356', '20190327', '600028', 5.71, 5.75, 5.69, 63601, 5.72, 1112544)
('1357', '20190328', '600028', 5.69, 5.7 , 5.62, 65692, 5.64, 1162484)
('1358', '20190329', '600028', 5.65, 5.75, 5.61, 112785, 5.74, 1981482)]
jddf:
id time code open_p colse_p low_p vol high_p col
0 1 20130902 600028 4.41 4.43 4.37 17275.39 4.41 392662
1 2 20130903 600028 4.41 4.46 4.40 19241.84 4.45 434177
2 3 20130904 600028 4.44 4.49 4.42 20106.30 4.47 451470
3 4 20130905 600028 4.47 4.48 4.42 15582.48 4.47 349997
4 5 20130906 600028 4.46 4.52 4.45 19101.41 4.50 425777
以上是資料準備----------------------------
各種變數的簡單統計描述 jddf.describe():
id time ... high_p col
count 1358.000000 1.358000e+03 ... 1358.000000 1.358000e+03
mean 679.500000 2.016016e+07 ... 5.668733 1.862497e+06
std 392.165144 1.638818e+04 ... 0.838200 2.301859e+06
min 1.000000 2.013090e+07 ... 4.270000 -1.656342e+07
25% 340.250000 2.015012e+07 ... 4.990000 6.711858e+05
50% 679.500000 2.016062e+07 ... 5.675000 1.063988e+06
75% 1018.750000 2.017111e+07 ... 6.190000 1.921891e+06
max 1358.000000 2.019033e+07 ... 8.670000 1.645562e+07
[8 rows x 9 columns]
用 scipy 進行各種變數的簡單統計描述:
describeresult(nobs=1358, minmax=(array([4.24, 4.29]), array([8.7 , 9.27])), mean=array([5.6587187 , 5.73196613]), variance=array([0.69569784, 0.74655759]), skewness=array([0.52696423, 0.58782836]), kurtosis=array([-0.29442338, -0.16281185]))
ALV台賬統計表
在sap開發中常常需要開發臺賬表,台賬的統計時間是變動的,我們通常會用臨時程式來處理。我這裡介紹乙個簡單的動態臺賬表 統計月份,周等在有限範圍內 的實現方法。1 申明內錶 data begin of gt list occurs 0,pernr like pa0001 pernr,員工編號 enam...
PB 製作統計表
看到統計表,就有一種感覺 哇塞!好高大上。這是最初看見功能的時候,自己就認為特別的難搞。但是當自己看了看資料,敲了敲之後發現,其實也不過就是乙個select語句,然後乙個控制項就完全搞定了。看一下 定義引數 integer thecount 5 seriesno integer i string t...
mysql學歷統計表 php mysql 統計表
原來你是這個意思,就是說統計每一道題選a的人就多少,選b的人有多少是吧,這樣子寫,我用php簡單寫了個,能執行出來.conn mysql connect localhost root mysql select db test conn mysql query set names utf 8 data...