time

How to change the date of time instance using python?

How to change the date of time instance using python? Question: I have start_time variable that stores a time string. start_time = ‘2022-12-21 22:00:00’ Now Using python i want to change the date of start time to start_time = ‘2022-12-28 22:00:00’ I have done this with very ugly approach. Please tell me easy and best …

Total answers: 2

How do I increment an variable in python every 10 seconds?

How do I increment an variable in python every 10 seconds? Question: So im trying to create an game where the day increase every 10 seconds and the player loses some of his stats, ive tried everything i could think of but im an beginner coder in python. I tried to understand the time/clock library …

Total answers: 1

Calculate age based on three dates

Calculate age based on three dates Question: I am trying to calculate the age of horses. All horses share the same birthday regardless of the date they were born – the 1st of August. For example, if a horse was born on 31st of July, it would still be classified as 1 yo despite only …

Total answers: 2

Pandas filter dataframe by time

Pandas filter dataframe by time Question: This is not a duplicate of: filter pandas dataframe by time because the solution offered there doesn’t address the same column type that needs to be filtered. I have the following dataframe: i = pd.date_range(‘2018-04-09′, periods=4, freq=’1D20min’) ts = pd.DataFrame({‘A’: [1, 2, 3, 4], ‘B’:i}) ts[‘date’] = pd.to_datetime(ts[‘B’]).dt.date ts[‘time’] …

Total answers: 1

Best method to measure execution time of a python snippet

Best method to measure execution time of a python snippet Question: I want to compare execution time of two snippets and see which one is faster. So, I want an accurate method to measure execution time of my python snippets. I already tried using time.time(), time.process_time(), time.perf_counter_ns() as well as timeit.timeit(), but I am facing …

Total answers: 1

TypeError: '>=' not supported between instances of 'builtin_function_or_method' and 'datetime.time'

TypeError: '>=' not supported between instances of 'builtin_function_or_method' and 'datetime.time' Question: I’m trying to compare two datetime.time values but I get this error: File "c:UsersxxxxxxDesktoppyfichecode.py", line 33, in timeofweek if (a.time >= d0.time() and a.time() <= d6.time()) or (a.time() >= d21.time() and a.time() <= d23.time()): TypeError: ‘>=’ not supported between instances of ‘builtin_function_or_method’ and ‘datetime.time’ …

Total answers: 1

How to break out of a While True loop in Python

How to break out of a While True loop in Python Question: I am reading cards in Python using an RFID Reader and I want to detect how long a card has been detected for in seconds, minutes and hours. The program begins to run once a card has been detected and starts the count …

Total answers: 1

Motion Builder 2019 Python setting custom framerate for plot options

Motion Builder 2019 Python setting custom framerate for plot options Question: I believe when setting plot options you set the fps using plot period with FBTime and an FBTimeMode. This seems to work for all preset time modes, but when setting to custom I can’t figure out how to set the fps of the custom …

Total answers: 1

How to get day of the week based on inputed date(Python)

How to get day of the week based on inputed date(Python) Question: So i wanted the user to enter date and based on that day to get named day of the week, for example today’s date is 2022.11.10, so wanted answer would be Thursday. I know this is wrong, can anybody help? import datetime def …

Total answers: 2