timedelta

How to calculate time between events in a pandas

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-22 09:58:05
问题 Original Question I'm stuck on the following problem. I'm trying to figure out at which moments in time and for how long a vehicle is situated at the factory. I have an excel sheet in which all events are stored which are either delivery routes or maintenance events. The ultimate goal is to obtain a dataframe in which the vehicle registration number is given with the corresponding arrival at the factory and the time spend there(including maintenance actions). For people interested, this is

Matplotlib timedelta64 index as x-axis

我的未来我决定 提交于 2020-01-14 19:07:02
问题 I want to plot a dataframe, which has a timedelta64 index with the index on the x-axis. The index looks like this: In [75]: test.index Out[75]: TimedeltaIndex([ '00:00:00', '00:00:00.020000', '00:00:00.040000', '00:00:00.060000', '00:00:00.080000', '00:00:00.100000', '00:00:00.120000', '00:00:00.140000', '00:00:00.160000', '00:00:00.180000', ... '07:29:31.660000', '07:29:31.680000', '07:29:31.700000', '07:29:31.720000', '07:29:31.740000', '07:29:31.760000', '07:29:31.780000', '07:29:31.800000

Matplotlib timedelta64 index as x-axis

吃可爱长大的小学妹 提交于 2020-01-14 19:06:46
问题 I want to plot a dataframe, which has a timedelta64 index with the index on the x-axis. The index looks like this: In [75]: test.index Out[75]: TimedeltaIndex([ '00:00:00', '00:00:00.020000', '00:00:00.040000', '00:00:00.060000', '00:00:00.080000', '00:00:00.100000', '00:00:00.120000', '00:00:00.140000', '00:00:00.160000', '00:00:00.180000', ... '07:29:31.660000', '07:29:31.680000', '07:29:31.700000', '07:29:31.720000', '07:29:31.740000', '07:29:31.760000', '07:29:31.780000', '07:29:31.800000

Matplotlib timedelta64 index as x-axis

社会主义新天地 提交于 2020-01-14 19:05:25
问题 I want to plot a dataframe, which has a timedelta64 index with the index on the x-axis. The index looks like this: In [75]: test.index Out[75]: TimedeltaIndex([ '00:00:00', '00:00:00.020000', '00:00:00.040000', '00:00:00.060000', '00:00:00.080000', '00:00:00.100000', '00:00:00.120000', '00:00:00.140000', '00:00:00.160000', '00:00:00.180000', ... '07:29:31.660000', '07:29:31.680000', '07:29:31.700000', '07:29:31.720000', '07:29:31.740000', '07:29:31.760000', '07:29:31.780000', '07:29:31.800000

Accessing datetime.now() values in Python

不问归期 提交于 2020-01-13 05:25:07
问题 I want to be able to implement a condition in my program where it would only run for N number of hours, maybe the user could specify N, but let's not jump ahead. I figured I could use datetime.now() and store the value below in a variable, time >>> time >>> time = datetime.datetime(2013, 12, 9, 21, 50, 32, 405329) Any ideas on how I can access the fourth field between the (--), seeing as it's a string? My condition would be something like while time != timeEnd where timeEnd would be the value

Using a SQLAlchemy Integer field to create a timedelta object for filtering

☆樱花仙子☆ 提交于 2020-01-10 04:15:35
问题 I have an object called Item. It has 2 fields: a datetime row called "created_on," and an integer row called "days." I want to query for all objects that were created "days" many days ago. Here's how I thought it should be done: now = utcnow() session.query(Item).filter(Item.created_on + Interval(timedelta(days=Item.days)) <= now) But I'm unable to create a timedelta like this. I'm getting this error: TypeError: unsupported type for timedelta minutes component: InstrumentedAttribute Update:

Session generation from log file analysis with pandas

元气小坏坏 提交于 2020-01-09 19:35:30
问题 I'm analysing a Apache log file and I have imported it in to a pandas dataframe. '65.55.52.118 - - [30/May/2013:06:58:52 -0600] "GET /detailedAddVen.php?refId=7954&uId=2802 HTTP/1.1" 200 4514 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"' My dataframe: I want to group this in to sessions based on IP, Agent and Time difference (If the duration of time is greater than 30 mins it should be a new session). It is easy to group the dataframe by IP and Agent but how

Session generation from log file analysis with pandas

梦想与她 提交于 2020-01-09 19:34:05
问题 I'm analysing a Apache log file and I have imported it in to a pandas dataframe. '65.55.52.118 - - [30/May/2013:06:58:52 -0600] "GET /detailedAddVen.php?refId=7954&uId=2802 HTTP/1.1" 200 4514 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)"' My dataframe: I want to group this in to sessions based on IP, Agent and Time difference (If the duration of time is greater than 30 mins it should be a new session). It is easy to group the dataframe by IP and Agent but how

pandas Timedelta error

只谈情不闲聊 提交于 2020-01-06 10:14:47
问题 I'm getting errors when running the code samples from the pandas documentation. I suspect it might be related to the version of pandas I'm using, but I haven't been able to confirm that. pandas VERSION 0.10.1 numpy VERSION 1.7.0 scipy VERSION 0.12.0.dev-14b1e07 The below examples are taken directly from the pandas documentation here: pandas - Time Deltas This works from datetime import datetime, timedelta from pandas import * s = Series(date_range('2012-1-1', periods=3, freq='D')) s Out[52]:

pandas Timedelta error

Deadly 提交于 2020-01-06 10:14:31
问题 I'm getting errors when running the code samples from the pandas documentation. I suspect it might be related to the version of pandas I'm using, but I haven't been able to confirm that. pandas VERSION 0.10.1 numpy VERSION 1.7.0 scipy VERSION 0.12.0.dev-14b1e07 The below examples are taken directly from the pandas documentation here: pandas - Time Deltas This works from datetime import datetime, timedelta from pandas import * s = Series(date_range('2012-1-1', periods=3, freq='D')) s Out[52]: