Skip to content
Advertisement

Tag: time

5-digit-year in date export (52164-01-19 00:00:00+00)

I received a data export from an unspecified source system, which includes dates in the format of: 52164-01-19 00:00:00+00 52992-08-12 04:29:36+00 52838-10-19 04:08:32.999936+00 54022-03-12 17:20:36.999936+00 I was told that the error is caused by a faulty conversion of unix to datetime (seconds and milliseconds). We came up with a possible approach to refactor the date in python, by separating the

Python does something every 5 minutes

i need to check data on an API. The API is refreshed with new data every 5 minutes (10:00, 10:05, 10:10 etc…) I don’t want to use time.sleep(300) because i want my script to do something at 10:05:03, then 10:05:03 etc. and not 5 min avec the script started (maybe it started at 10h12 How can i build this? Thanks

In Discord.py, is it possible to wait for a variable to change from a different part of the code than the variable changes?

I tried using time.sleep(), but instead of waiting for the variable it paused the whole code, not allowing the variable to change. This is my code: I can’t figure out what to replace time.sleep(1.0) with. Answer You can use await asyncio.sleep(1) instead. Asyncio.sleep works like time.sleep, but it doesn’t block the entire code execution. It stops only one event. Meanwhile,

Setting Time with interval of 1 minute

I have a dataset which comprises of minutely data for 2 stocks over 3 months. I have to create date in the first column and time (with interval of 1 minute) in the next column for 3 months. I am attaching the snap of 1 such data set. Kindly help me to solve this problem. Data Format Answer -Create 3

Optimizing python script to produce output faster (Variable Assignment)

I am using python for optimization purposes. I made a graph using Networkx library with 1100 nodes. The python script includes the following lines. In the next step, some random numbers are generated as follows: I compute the distance between nodes in the graph using the following function. Finally, I defined the variable “shipping_cost” as: Every line of the above

how do i get only the time in python without the date and year?

I need to get time in python and i am using time.ctime() and it returns this Thu Jul 8 15:37:26 2021 But i only need 15:37:26 and i cant figure out how to get only this and not the date and year. I already tried using datetime where i could not figure it out either so im trying with time

Python print the same timestamp the same anywhere

I’m given a timestamp in seconds, and I ‘inherited’ a function to print it in human-readable form, but the function is locale-specific; that is, it matters what time zone the host is configured for. I want to print that time as GMT no matter what time zone I’m in. For example, here’s the sequence on a computer in Mountain Time

Advertisement