① 列( ⇩ ) : 辞書指定
df_col = pd.DataFrame({ 'col_name1' : ['val_11' , 'val_12' , 'val_13'],
'col_name2' : ['val_21' , 'val_22' , 'val_23'],
'col_name3' : ['val_31' , 'val_32' , 'val_33'],
})
print ( df_col )
# col_name1 col_name2 col_name3
# 0 val_11 val_21 val_31
# 1 val_12 val_22 val_32
# 2 val_13 val_23 val_33
② 行( ⇨ ) : リスト指定
df_ind = pd.DataFrame([ ['val_11' , 'val_12' , 'val_13'],
['val_21' , 'val_22' , 'val_23'],
['val_31' , 'val_32' , 'val_33'],
])
print ( df_ind )
# 0 1 2
# 0 val_11 val_12 val_13
# 1 val_21 val_22 val_23
# 2 val_31 val_32 val_33
③ 行列 : index , columns指定
df_colind = pd.DataFrame([ ['val_11' , 'val_12' , 'val_13'],
['val_21' , 'val_22' , 'val_23'],
['val_31' , 'val_32' , 'val_33']],
index = [ ind_1 , ind_2 , ind_3 ],
columns = [ col_1 , col_2 , col_3 ]
)
print ( df_colind )
# col_1 col_2 col_3
# ind_1 val_11 val_12 val_13
# ind_2 val_21 val_22 val_23
# ind_3 val_31 val_32 val_33