Skip to content

Instantly share code, notes, and snippets.

@Khanashima
Last active January 23, 2016 15:51
Show Gist options
  • Save Khanashima/16e77e989e1eea4eca2f to your computer and use it in GitHub Desktop.
Save Khanashima/16e77e989e1eea4eca2f to your computer and use it in GitHub Desktop.
【Python】pandasのSeries、DataFrameとは ref: http://qiita.com/kiimiiis/items/0e1646adf0dab0061845
#数値計算ライブラリインポート
import numpy
#データ分析ライブラリからSeriesとDataFrameをインポート
from pandas import Series, DataFrame
#Series
#data仮引数 : データ。array-like, dict, or scalar value
#index仮引数 : データの添え字。array-like or Index (1d)
#dtype仮引数 : データタイプ。numpy.dtype or None
#copy仮引数 : コピー。デフォルトはfalse
#name仮引数 : 結果につける名前
#1
print(Series(data=[0,1]))
#2
print(Series(data=[2,3], index=['x', 'y'], name='value'))
#DataFrame
#data仮引数 : データ ( numpy ndarray (structured or homogeneous), dict, or DataFrame)
#index仮引数 : 要素のインデックス。デフォルトは添え字配列みたいに数字
#columns仮引数 : 2次元のインデックス。デフォルトは数字
#dtype仮引数 : データタイプ。dtype, default None
#copy仮引数 : コピー。デフォルトはfalse。
#3
print(DataFrame(numpy.array([[0,0],[1,1]])))
#4
print(DataFrame(numpy.array([[0,0],[1,1]]), index=['a', 'b']))
#5
print(DataFrame(numpy.array([[0,0],[1,1]]), index=['a', 'b'], columns=['x', 'y']))
#1
0 0
1 1
dtype: int64
#2
x 2
y 3
Name: value, dtype: int64
#3
0 1
0 0 0
1 1 1
#4
0 1
a 0 0
b 1 1
#5
x y
a 0 0
b 1 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment