Skip to content

Tag: datetime

Combining weeks 52 and 0 with Python Datetime

I have a Pandas DataFrame with daily data that I’m trying to group by week number to sum some columns, and I notice that when years do not begin on Sunday, the data for the week spanning the end of one year and the beginning of the next do not cleanly sum, instead being broken into two groups. My code

Separate columns of a DataFrame by days of the week

Let it be the following Python Panda Dataframe (the original could include dates for several months): Hours 2022-06-06 2022-06-07 2022-06-08 2022-06-09 2022-06-10 2022-06-11 2022-06-12 2022-06-13 2022-06-14 2022-06-15 2022-06-16 2022-06-17 2022-06-18 2022-06-19 00:00 3 0 0 3 23 43 1 2 3 3 7 3 1 0 05:00 5 4 0 …

how to divide a datetime object by an int

I can’t seem to divide a datetime.time object by an int. Looking at the documentation I can’t figure out why it isn’t working. I get the error: unsupported operand type(s) for /: ‘datetime.time’ and ‘int’. I did see a method that splits the time down into second then …