a 0
b 1
c 2
d 3
Name: 2020-04-08 00:00:00, dtype: int32
#输出ab列的所有数据
df.loc[:,['a','b']]
a
b
2020-04-08
0
1
2020-04-09
4
5
2020-04-10
8
9
2020-04-11
12
13
2020-04-12
16
17
2020-04-13
20
21
df.loc['20200408',['a','b']]
a 0
b 1
Name: 2020-04-08 00:00:00, dtype: int32
用iloc进行纯索引输出
#输出第三行第一位的数据
df.iloc[3,1]
13
#输出多行多列数据
df.iloc[3:5,1:3]
b
c
2020-04-11
13
14
2020-04-12
17
18
#指定具体索引输出
df.iloc[[1,3,5],[0,3]]
a
d
2020-04-09
4
7
2020-04-11
12
15
2020-04-13
20
23
用ix进行标签名+索引混合输出 (ix以及被放弃了)
df.ix[:3,['a','c']]
D:\Anaconda3\lib\site-packages\ipykernel_launcher.py:1: DeprecationWarning:
.ix is deprecated. Please use
.loc for label based indexing or
.iloc for positional indexing
See the documentation here:
http://pandas.pydata.org/pandas-docs/stable/indexing.html#ix-indexer-is-deprecated
"""Entry point for launching an IPython kernel.