LernerPython ブログ、Reuven Lerner... ノート

LernerPython ブログ、Reuven Lerner より: Pandas 日付範囲選択: .loc を使用した datetime インデックスのスライス

Python Pandas データフレームから時間の塊を選択したいですか?datetime 列をインデックスにし、.loc とスライスを使用して日付を選択します。( df .set_index('tpep_pickup_datetime') .sort_index() .loc['2025-11-10':'2025-11-20'] ['trip_distance'] .mean() )
CdXz5zHNQW_m7T8KjdrIO.png