Skip to content

Instantly share code, notes, and snippets.

@kemsakurai
Last active May 5, 2018 08:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kemsakurai/3f2c5ad0638391e01fd687bd5fa8bd88 to your computer and use it in GitHub Desktop.
Save kemsakurai/3f2c5ad0638391e01fd687bd5fa8bd88 to your computer and use it in GitHub Desktop.
python 辞書をマージする (キー重複した場合は、Value をリスト化)

辞書のマージがしたかった。辞書のマージといっても、色々あり、検索の仕方が難しい。
キー重複した場合、Value をリスト化したかった。
以下、Stack Overflow の質問が参考になった。

Valueが数値で、合計を計算したい場合は、collections の Counter を使う。

Taple の key value ペアの dictionary化をする。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment