我有数据框架格式的1 000个浏览器的日数据,我需要在连续几行之间找到时间。 但不幸的是,我似乎找不到一种办法,可以分拨和使用时间模块收集这些信息。
期望使用数据时间模块,但似乎无法找到正确的方式来分立数据并找到时间差异。
I write some motivations for my answer below. Feel free to check out <>Answer to skip all this.
<>Exploration
为了模拟你的数据,我使用了以下代码:
vals = [ 20231116032619 , 20231116032640 , 20231116032641 , 20231116032644 , 20231116032646 , 20231116032648 , 20231116032650 , 20231116032652 , 20231116032654 , 20231116032656 , 20231116032659 ]
data = {"date": vals}
df = pd.DataFrame(data)
我将一栏中的数值表示为示意图(目标)。 如果是,我们可能希望将每一种价值转换成一个星体,使用。
I m also assuming that the strings represents year, month, day, hour, minute second. For example 20231116032640
represents `November 16, 2023 03:26:40".
首先,我们要将这一栏改为适当的 。 方法。
一旦我们完成这项工作,我们便能够简单地利用以下推算方法,即:-方法,以及最后一段时间的计量单位,例如
在假体编码方面,这大致如下: | delta(sec) |
| -------------- |
| 21 |
| 1 |
... etc <>Answer 我们大家一起努力,我们可以写出如下内容: 这导致第一行的<代码>NaN值,但可以轻易处理。 | delta(sec) |
| -------------- |
| NaN |
| 21.0 |
| 1.0 |
| 3.0 |
| 2.0 |
| 2.0 |
... etc 希望这一帮助! 幸福 co。convert date to datetime
delta = (date column - shift 1 back).seconds
df["date"] = pd.to_datetime(df["date"], format="%Y%m%d%H%M%S")
delta = (df["dates"] - df["dates"].shift(1)).dt.seconds
Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...
I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...
Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...
Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...
I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...
Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...
Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...
I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...