我有一个numpy数组的形式:
np.Array1 =
[
['2019-12-01' '0.03555' '0.03' '0.03' '0.03'],
['2019-12-02' '0.03' '0.03' '1' '0.03']
]
第二点:
np.Array2 =
[
array(['2019-12-01', '1', '1', '1', '1']),
array(['2019-12-02', '1', '1', '1', '20'])
]
我有没有办法这样做:
求每个元素的和,其中npArray1.col1 = npArray2.col1
-即:当日期相同时,逐个元素添加(不包括日期)
'2019-12-01' = '2019-12-01' so [0.03555+1, 0.03+1, 0.03+1, 0.03+1]
我发现我的做法是错误的,在同一个数组中改变类型
任何关于基于条件逻辑的更好的增值方法的建议都值得赞赏
这对我来说很有效,不需要熊猫:
您可以通过将数组转换为以日期为索引的数据帧,并使用
add
来实现这一点:然后,通过将其转换回字符串、重置索引并获取以下值,可以将其作为原始格式的numpy数组取回:
相关问题 更多 >
编程相关推荐