import pandas as pd
s = pd.Series([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20])
output:
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
dtype: int64我想把这个系列分成四个系列,具体如下:
f 210之间的数字。
发布于 2020-07-27 09:00:59
试着使用:
import pandas as pd
s = pd.Series([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20])
s1 = s[0:5]
s2 = s[5:10]
s3 = s[10:15]
s4 = s[15:]发布于 2020-07-27 09:08:24
你可以使用numpy的array_split()
s_split = np.array_split(s, 4)[0 1
1 2
2 3
3 4
4 5
dtype: int64,
5 6
6 7
7 8
8 9
9 10
dtype: int64,
10 11
11 12
12 13
13 14
14 15
dtype: int64,
15 16
16 17
17 18
18 19
19 20
dtype: int64]通过s_split[0],..s_split[1]访问它们
https://stackoverflow.com/questions/63111744
复制相似问题