0
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 5 years have passed since last update.

pandas.to_jsonの挙動

Posted at

概要

pandas.to_jsonの挙動を調べてみた。

サンプルコード

import pandas as pd

df = pd.DataFrame([['a0', 'b0', 'c0'], ['a1', 'b1', 'c1']], index = ['taro', 'jiro'], columns = ['sono1', 'sono2', 'sono3'])
print (df.to_json(orient = 'split'))
print (df.to_json(orient = 'records'))
print (df.to_json(orient = 'index'))
print (df.to_json(orient = 'columns'))
print (df.to_json(orient = 'values'))

結果

{"columns":["sono1","sono2","sono3"],"index":["taro","jiro"],"data":[["a0","b0","c0"],["a1","b1","c1"]]}
[{"sono1":"a0","sono2":"b0","sono3":"c0"},{"sono1":"a1","sono2":"b1","sono3":"c1"}]
{"taro":{"sono1":"a0","sono2":"b0","sono3":"c0"},"jiro":{"sono1":"a1","sono2":"b1","sono3":"c1"}}
{"sono1":{"taro":"a0","jiro":"a1"},"sono2":{"taro":"b0","jiro":"b1"},"sono3":{"taro":"c0","jiro":"c1"}}
[["a0","b0","c0"],["a1","b1","c1"]]

成果物

以上。

0
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
0
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?