1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

dictのdictをDataFrameにする

Last updated at Posted at 2021-02-26

dictのdictをDataFrameに変換したい

以下のようなdictを一発でデータフレームにしようとしました。

data = {
    '1001': { 'A1' : '1', 'A2', '2' },
    '1002': { 'A1' : '3', 'A2', '4' },
}

1001,1002を index に、その後ろのdictのkeyを列にvalueを値にしたい

以下でOKです!

df = pd.DataFrame.from_dict(data, orient='index')

print(df)

結果


     A1 A2
1001  1  2
1002  3  4

以上となります。
ご参考にー

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?