ablog

不器用で落着きのない技術者のメモ

pandas

pandas で df[df[列番号]==数値] と df[df[列番号].isin([数値])] のどちらが速いか(数値編)

サマリー 14MBの CSV ファイルを読んで 1,000 回 df[df[列番号]==数値] または df[df[列番号].isin([数値])] の実行時間を計測すると、isin のほうが 0.875s(=3.131s-2.256s)遅い結果になった。cProfile でプロファイリングすると df[df[列番号]==数値] の…

Python データ処理チートシート

Gropu By Multiple functions can also be applied at once. For instance, say we’d like to see how tip amount differs by day of the week - agg() allows you to pass a dictionary to your grouped DataFrame, indicating which functions to apply to…

pandas で csv_read すると "Unnamed: 1" といったカラムが追加される

事象 pandas で csv_read すると "Unnamed: 1" といったカラムが追加される 原因 よく見るとヘッダにタブが 2 つ入っていたので、1 つに修正したらお直った。 # hostname と date の間に 2 つタブが入っている hostname date timestamp kbmemfree kbmemused …