Skip to content

Tag: datetime

Remove data time older than specific hours

I want to remove data from my dataframe older than say 2 hours from current time starting with 00 mins (datetime column is in index) when i use below code Current datetime: ’17-03-2022 17:05:00′ Issue: My code keeps all records in df from ’17-03-2022 15:05:00′ to ’17-03-2022 17:0…

Get cumulative sum in pandas

Context Datetime Campaign_name Status Open_time 2022-03-15 00:00 Funny_campaign Open 2022-03-15 01:00 Funny_campaign Continue 2022-03-15 02:00 Funny_campaign Continue 2022-03-15 03:00 Funny_campaign Continue 2022-03-15 04:00 Funny_campaign Close 2022-03-15 08:00 Funny_campaign Open 2022-03-15 09:00 Funny_camp…

Is pandas.read_spss misreading datetime into unix?

I have a sav file with a datetime column in %m/%d/%Y string format. When I read it in with pd.read_spss(), which doesn’t seem to have any datetime-related arguments, it ends up in what looks like unix time, except that the time would be a few centuries from now with unique values including 13778726400, …

CET timezone strings to datetime

I have a data frame that has columns looking similar to this. This data is imported from SQL into a Pandas data frame, and when I print out the dtypes I can see that the date_cet column is object. Since I need it further on, I want to convert it to a datetime object. However, the stuff I’ve tried just