Python 3.x: Merge two dictionaries with same keys and values being array

后端 未结 4 1320
遥遥无期
遥遥无期 2021-01-20 12:13

Python version: 3.x

I have two dictionaries with same keys and the values are arrays. Most of the questions I saw here, for the required purpose, have only one value

4条回答
  •  旧巷少年郎
    2021-01-20 12:31

    I believe you need smth like:

    {key:np.append(d1[key], d2[key]) for key in d1.keys()}
    

    Not sure about np.append though. And, of course, it will work only if dicts have the same keys.

提交回复
热议问题