datetime

Find all files matching given path format with datetime

Find all files matching given path format with datetime Question: I’m looking to identify all files whose path matches a given format (for example %Y/%j/data_%d.txt) and retrieve the associated date. A simple solution is to use strptime, but this doesn’t work if a ‘format code’ appears twice in the format (e.g. %Y/%j/data_%Y%m%d.txt). This is a …

Total answers: 1

How to convert timedelta in data frame to datetime

How to convert timedelta in data frame to datetime Question: I have couple columns in df with avg time, example "0 days 00:00:21". I want convert all columns to datetime.time format "hh:mm:ss" without "0 days". How can I do this? my df Asked By: Grzegorz Z || Source Answers: not sure how you data is …

Total answers: 2

Convert column to Numpy within a select statement in Polars

Convert column to Numpy within a select statement in Polars Question: I am trying to transform a date column to the next business day after each date (if the date isn’t already a business day in which case it remains unchanged). To do this I am using a Numpy function called busday_offset which takes a …

Total answers: 1

Sum values associated with time intervals where intervals overlap in python

Sum values associated with time intervals where intervals overlap in python Question: Say I have a pandas data frame where there are time intervals between start and end times, and then a value associated with each interval. import random import time import numpy as np def random_date(input_dt = None): if input_dt is None: start = …

Total answers: 1

How can I display error bars an a datetime.datetime axis?

How can I display error bars an a datetime.datetime axis? Question: I’m trying to make a plot with error bars along the time axis, ideally with adjustable upper/lower error limits. I’ve been using the datetime.datetime datatype to do this, which has been reliable until I’ve tried to implement error bars with matplotlib.pyplot.errorbar(). import matplotlib.pyplot as …

Total answers: 2

How to format datetimes in Power BI for a matplotlib visualization

How to format datetimes in Power BI for a matplotlib visualization Question: I have a problem with the Power BI dataset that I could not resolve in the past month so In the below picture you can see my steps which are numbered. In the first step, you can see my data source which is …

Total answers: 1

Datetime / Unix Date convertor

Datetime / Unix Date convertor Question: I need an input prompt that will allow the user to enter a date at the point the function is called and then run to concert the date to Unix date for an API call later in the program. At the moment every attempt seems to hand back an …

Total answers: 1

How to calculate current time in different timezone correctly in Python

How to calculate current time in different timezone correctly in Python Question: I was trying to calculate the current time in NYC (EST time aka Eastern Daylight time or GMT+4) given current time in Israel (Israel daylight time, currently GMT+3) where I’m currently located. So right now Israel is 7 hrs ahead of NYC, but …

Total answers: 1

Convert python datetime to custom epoch time

Convert python datetime to custom epoch time Question: I need to convert datetime to a format where the whole number portion of the value (left of the decimal) counts the days since December 30, 1899. The fractional portion (right of the decimal) counts the time as a fraction of one day. For example, January 1, …

Total answers: 1