Skip to content
Advertisement

Downsample non timeseries pandas dataframe

I have a data frame like below,

JavaScript
JavaScript

I want to reduce the size of data frame by Depth_Feet column (let’s say every 2 feet). Desired output is

JavaScript

I have tried few options like round and group by etc, but I’m not able to get the result I want.

Advertisement

Answer

If need each 2 rows per groups:

JavaScript

If need resample by 2 per groups convert values to TimedeltaIndex:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement