Finology 大数据金融

通过大数据以量化金融

整理得最全的提取Series或DataFrame数据的公式。

提取单个元素

基于位置提取数据

s[index]
s.iat[index]
df.iat[row_index, col_index]

基于 label 提取数据

s[label]
s.at[label]
df.at[row_label, col_label]

提取多个元素

对于 Series

基于位置提取

s[a:b]
s[[a,b,c]]
s.iloc[a:b]
s.iloc[[a,b,c]]

基于标签提取

s[label1:labeln]
s[[label1, label2, label3]]
s.loc[label1:labeln]
s.loc[[label1, label2, label3]]

对于 DataFrame

基于位置

行列 中括号 iloc
单行 df[a:a+1] df.iloc[a]等价于df.iloc[a,:]、df.iloc[[a]]等价于df.iloc[[a],:]
多行 df[a:b] df.iloc[a:b]等价于df.iloc[a:b,:]、df.iloc[[a,b,c]]等价于df.iloc[[a,b,c],:]
单列 - df.iloc[:,a]、df.iloc[:,[a]] (:不能省略)
多列 - df.iloc[:,a:b]、df.iloc[:,[a,b,d]]
行列 - df.iloc[a:b,n:m]、df.iloc[[a,b,c],[n,m]]

基于标签

行列 中括号 loc
单行 - df.loc[label]、df.loc[[label]]
多行 - df.loc[lable1:lable3]、df.loc[[lable1,lable2,…]]
单列 df[clo1]、df[[col1]] df.loc[:,col]、df.loc[:,[col]] (:不能省略)
多列 df[[clo1,col2]] df.loc[:,[col1,col2]] 、df.loc[:,col1:col4]]
行列 - df.loc[lable1:lable3,col1:col4]]、df.loc[[lable1,lable2,…],[clo1,col2]

主题用的是”山吹”,下面自定义设置的样式。

外边距设置为 2px ,不然外边距有些大。

1
2
3
#nice {
padding: 2px;
}

字体设置为 17px, 对齐方式为两边对齐。

1
2
3
4
5
#nice p {
font-size: 17px;
text-align: justify;
...
}

WebSocket Cat (wscat)是一个连接websocket的小工具。

安装方法

1
npm install -g wscat

使用方法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Usage: wscat [options] (--listen <port> | --connect <url>)

Options:
-V, --version output the version number
-l, --listen <port> listen on port
-c, --connect <url> connect to a WebSocket server
-p, --protocol <version> optional protocol version
-o, --origin <origin> optional origin
-x, --execute <command> execute command after connecting
-w, --wait <seconds> wait given seconds after executing command
-P, --show-ping-pong print a notification when a ping or pong is received
--host <host> optional host
-s, --subprotocol <protocol> optional subprotocol (default: [])
-n, --no-check do not check for unauthorized certificates
-H, --header <header:value> set an HTTP header. Repeat to set multiple (--connect only) (default: [])
--auth <username:password> add basic HTTP authentication header (--connect only)
--ca <ca> specify a Certificate Authority (--connect only)
--cert <cert> specify a Client SSL Certificate (--connect only)
--key <key> specify a Client SSL Certificate's key (--connect only)
--passphrase [passphrase] specify a Client SSL Certificate Key's passphrase (--connect only). If you don't provide a value, it will be prompted for
--no-color run without color
--slash enable slash commands for control frames (/ping, /pong, /close [code [, reason]])
--proxy <[protocol://]host[:port]> connect via a proxy. Proxy must support CONNECT method
-h, --help

使用案例

在终端1启动一个websocket服务,监听9000端口。

1
2
wscat --listen 9000
Listening on port 9000 (press CTRL+C to quit)

在终端2连接上websocket服务。

1
2
wscat -c ws://localhost:9000/echo
Connected (press CTRL+C to quit)

连上以后,在服务端,会提示信息:

Client connected

然后就可以两端互相发送消息了。

0%