Skip to content

Tag: datetime

Pandas datetime filter

I want to get subset of my dataframe if date is before 2022-04-22. The original df is like below df: I checked data type by df.dtypes and it told me ‘date’ column is ‘object’. So I checked individual cell using df[‘date’][0] and it is datetime.date(2022, 4, 21). Also, df[&#…

Count number of days in each continuous period pandas

Suppose I have next df N03_zero (date_code is already datetime): Millions of rows with date_code assigned to some item_code. I am trying to get the number of days of each continuous period for each item_code, all other similar questions doesn’t helped me. The expected df should be: Once days sequence br…