Python dataframe - how to round datatime series to the next business day at a specific time | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Python dataframe - how to round datatime series to the next business day at a specific time

Hi all I have a column of datetime in a Python dataframe. These dates consist of non-busess days such as times on Saturdays and Sundays, and I would like to round these dates to, say, 10am of the next business day. For example, if(dt.weekday = =6 | dt.weekday ==7), then the next business day at 10:00. Is this possible??

25th Aug 2021, 10:51 AM
Jin
Jin - avatar
1 Answer
+ 1
So you are using pandas DataFrames? Which format do your datetime objects have? And could you please send your code, this would be very helpful. Btw, what you describe is possible, if I understood it right. In the example, the python syntax should be: # example code begin if dt.weekday == 6 or dt.weekday == 7: # \t some code # example code end
30th Aug 2021, 3:47 PM
Maisu
Maisu - avatar