小编Kru*_*h23的帖子

计算两个列表中的相同对

我的清单有

a = [1,2,3,4,2,7,3,5,6,7]
b = [1,2,3,1,2,5,6,2,6,7]
Run Code Online (Sandbox Code Playgroud)

我需要数一下a[i]==b[i]

对于以上示例,答案应为

6
Run Code Online (Sandbox Code Playgroud)

答案的详细说明是

a[0]==b[0] (1==1)
a[1]==b[1] (2==2)
a[2]==b[0] (3==3)
a[4]==b[4] (2==2)
a[8]==b[8] (6==6)
a[9]==b[9] (7==7)
Run Code Online (Sandbox Code Playgroud)

python list python-3.x

16
推荐指数
3
解决办法
1167
查看次数

如何为python中的列创建转换矩阵?

如何将 B 列转换为 python 中的转换矩阵?

矩阵的大小为 19,这是 B 列中的唯一值。数据集中共有 432 行。


time                A          B
2017-10-26 09:00:00  36       816
2017-10-26 10:45:00  43       816
2017-10-26 12:30:00  50       998
2017-10-26 12:45:00  51       750
2017-10-26 13:00:00  52       998
2017-10-26 13:15:00  53       998
2017-10-26 13:30:00  54       998
2017-10-26 14:00:00  56       998
2017-10-26 14:15:00  57       834
2017-10-26 14:30:00  58      1285
2017-10-26 14:45:00  59      1288
2017-10-26 23:45:00  95      1285
2017-10-27 03:00:00  12      1285
2017-10-27 03:30:00  14      1285
                             ... 
2017-11-02 14:00:00  56       998
2017-11-02 14:15:00  57       998
2017-11-02 …
Run Code Online (Sandbox Code Playgroud)

python pandas

5
推荐指数
1
解决办法
2217
查看次数

连接两个数组Python

我有大小为A (1, 1, 59)和B的数组(1, 95, 59)。我想连接数组。数组的大小应为(1, 96, 59)

np.concatenate((A, B),axis =0)
Run Code Online (Sandbox Code Playgroud)

不起作用 错误是ValueError: all the input array dimensions except for the concatenation axis must match exactly

python arrays numpy

4
推荐指数
1
解决办法
58
查看次数

标签 统计

python ×3

arrays ×1

list ×1

numpy ×1

pandas ×1

python-3.x ×1