あれもPython,これもPython

Pythonメモ※本サイトはアフィリエイトを利用しています

2020-06-26から1日間の記事一覧

PandasでWindow関数(行移動:lagなどを再現したい(shift()を使う)

Pandasでlag,lead,first_value,last_valueなどを再現します。 lag(col,1) over(order by sort_col) ,first_value(col) over(order by sort_col) lag,lead系 shiftを使います。 shiftはwindow関数のorder by句のような変数はないため、先にソートして使う必要…