1,pandas操作主要有对指定位置的赋值,如上一篇中的数据选择一样,根据loc,iloc,ix选择指定位置,直接赋值
2,插入,insert方法,插入行和列
3,添加
4,删除 drop方法
5,弹出 pop方法
In [1]:
import pandas as pd
import numpy as np
In [53]:
dates = np.arange(20190809,20190815)
df1 = pd.DataFrame(np.arange(24).reshape(6,4),index=dates,columns=["A","B","C","D"])
df1
Out[53]:
A
B
C
D
20190809
0
1
2
3
20190810
4
5
6
7
20190811
8
9
10
11
20190812
12
13
14
15
20190813
16
17
18
19
20190814
20
21
22
23
In [20]:
df1.iloc[2,2]
Out[20]:
10
In [44]:
df1.iloc[2,2] = 100
df1
Out[44]:
A
B
C
D
20190809
0
1
2
3
20190810
4
5
6
7
20190811
8
9
100
11
20190812
12
13
14
15
20190813
16
17
18
19
20190814
20
21
22
23
In [40]:
df1.loc[20190810,"B"]=200
df1
Out[40]:
A
B
C
D
20190809
0
1
2
3
20190810
4
200
6
7
20190811
8
9
10
11
20190812
12
13
14
15
20190813
16
17
18
19
20190814
20
21
22
23
In [54]:
df1[df1.A>10]=0
df1
Out[54]:
A
B
C
D
20190809
0
1
2
3
20190810
4
5
6
7
20190811
8
9
10
11