LoginSignup
1
1

More than 5 years have passed since last update.

pandas.DataFrameをつかってみる

Posted at

jsonのデータがいっぱいある系

a = [{"poko": 1, "hoge":2}, {"poko": 1, "hoge":2}, {"hoge":2}, {"poko": 1}]

みたいな

from pandas import DataFrame
frame = DataFrame(a)

ipython でframeを出力すると

Out:
   hoge  poko
0     2     1
1     2     1
2     2   NaN
3   NaN     1

的な

In: frame[“poko”]
Out: 
0     1
1     1
2   NaN
3     1
Name: poko, dtype: float64

In: frame[“poko”][:2]
Out: 
0    1
1    1
Name: poko, dtype: float64

みたいな

カウントアップがほしいとき

In: frame["poko"].value_counts()
Out:
1    3
dtype: int64

みたいに

1
1
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
1