ちょっと空のDataFrameが必要となり作り方をチェックチェック。 In [151]: df = pd.DataFrame(index=[1,2], columns=[1,2]) In [153]: df Out[153]: 1 2 1 NaN NaN 2 NaN NaN In [154]: df.fillna('aaa') Out[154]: 1 2 1 aaa aaa 2 aaa aaa じゃじゃーん。 なーいす。
Taking care of business, one python script at a time Introduction Most people likely have experience with pivot tables in Excel. Pandas provides a similar function called (appropriately enough) pivot_table . While it is exceedingly useful, I frequently find myself struggling to remember how to use the syntax to format the output for my needs. This article will focus on explaining the pandas pivot_
In [86]: df Out[86]: <class 'pandas.core.frame.DataFrame'> Int64Index: 2634 entries, 0 to 2633 Data columns (total 8 columns): 0 2634 non-null values 1 2634 non-null values 2 2634 non-null values 3 2634 non-null values 4 2634 non-null values 5 2634 non-null values 6 2634 non-null values diff 2634 non-null values dtypes: float64(5), int64(1), object(2) In [87]: rows = random.sample(df.index.tolist(
なんかぼやぼやしているうちにひさびさの pandas エントリになってしまった。基本的な使い方については網羅したい気持ちはあるので、、、。 今回は データの連結 / 結合まわり。この部分 公式ドキュメント がちょっとわかりにくいので改訂したいなと思っていて、自分の整理もかねて書きたい。 公式の方はもう少し細かい使い方も載っているのだが、特に重要だろうというところだけをまとめる。 連結 / 結合という用語は以下の意味で使っている。まず憶えておいたほうがよい関数、メソッドは以下の 4 つだけ。 連結: データの中身をある方向にそのままつなげる。pd.concat, DataFrame.append 結合: データの中身を何かのキーの値で紐付けてつなげる。pd.merge, DataFrame.join 連結 (concatenate) 柔軟な連結 pd.concat ふたつの DataFram
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く