为什么要按日期时间连接数据集?
科学家和工程师面临的常见数据准备挑战之一是按日期、时间或日期时间(也称为时间戳)匹配不同的数据集(图 1)。
Figure 1. Example of dates, time and datetime data.Figure 1. Example of dates, time and datetime data.Figure 1. Example of dates, time and datetime data.Figure 1. Example of dates, time and datetime data.图1。 日期、时间和日期时间数据的示例。
科学家和工程师经常从各种不同的测量系统/设备中获取指标。 为了分析数据,他们需要将所有指标合并到一个表中,以便可以查看所有指标之间的关系。
当您有唯一标识符列或一组列(例如 Batch_ID、Lot_ID、UPC、序列号等)时,连接相对简单,可以使用 JMP 中的表 > 连接功能或虚拟连接功能在 JMP 中。
当您需要在数据集之间对齐日期、时间或日期时间时,这就更具挑战性。 通常,该任务涉及随着时间的推移连续跟踪指标(例如温度、压力、pH 值、葡萄糖)的传感器。 要了解这些指标如何影响产品端点(有时称为“关键质量属性”),有必要在适当的时间段内创建这些指标的摘要*。 然后将摘要与相应的产品端点连接起来。
让我们通过一个案例研究来展示如何完成这种类型的连接。
案例分析
观看视频,或阅读视频下方的案例研究。
我们试图理解和改进的过程产生了一种名为“Forever Young Elixir”的成品。关键的质量属性是效力。
产品分两步生产。 首先,原材料进入对原材料施加压力的机器。 然后,组装好的原材料进入第二个工艺步骤,在该步骤中施加温度以形成最终产品。

这两个工艺步骤都可以控制,但目前存在相当多的变化,我们认为这些变化正在影响成品的关键质量属性效力。 我们有兴趣了解压力和温度如何影响该产品的效力,以便最终我们可以确定每个工艺步骤的可接受的操作范围。 有温度和压力传感器连续监控过程。
在本例中,我们将重点关注温度,因为处理压力数据的过程是类似的。
我们有一个数据表,其中包含每个批次、该批次完成时的时间戳(日期时间)及其效力(图 2)。
Figure 2. Potency data collected for each finished batch along with the timestamp for batch completion.Figure 2. Potency data collected for each finished batch along with the timestamp for batch completion.Figure 2. Potency data collected for each finished batch along with the timestamp for batch completion.Figure 2. Potency data collected for each finished batch along with the timestamp for batch completion.图 2. 为每个完成批次收集的效力数据以及批次完成的时间戳。我们还有来自温度传感器的数据。 每隔一分钟记录一次温度(图 3)。
Figure 3. Potency data collected for each finished batch along with the timestamp for batch completion.Figure 3. Potency data collected for each finished batch along with the timestamp for batch completion.Figure 3. Potency data collected for each finished batch along with the timestamp for batch completion.Figure 3. Potency data collected for each finished batch along with the timestamp for batch completion.图 3. 为每个完成批次收集的效力数据以及批次完成的时间戳。
最终,为了将效力与温度关联起来,我们需要一个表格,其中包含每个批次的效力以及产品制造期间的平均*温度。
Figure 4. Final analysis table with temperature data combined with potency data. *Other summary statistics could be considered, or one could also explore using the Functional Data Explorer platform which uses all of the data to understand a process instead of summarizing to a single value.Figure 4. Final analysis table with temperature data combined with potency data. *Other summary statistics could be considered, or one could also explore using the Functional Data Explorer platform which uses all of the data to understand a process instead of summarizing to a single value.Figure 4. Final analysis table with temperature data combined with potency data. *Other summary statistics could be considered, or one could also explore using the Functional Data Explorer platform which uses all of the data to understand a process instead of summarizing to a single value.Figure 4. Final analysis table with temperature data combined with potency data. *Other summary statistics could be considered, or one could also explore using the Functional Data Explorer platform which uses all of the data to understand a process instead of summarizing to a single value.图 4. 最终分析表包含温度数据和效力数据。 *可以考虑其他汇总统计数据,或者也可以使用功能数据浏览器平台进行探索,该平台使用所有数据来理解流程,而不是汇总为单个值。

在进入软件之前,我们需要确定温度步骤中的哪些时间点与特定批次适当关联。 换句话说,该批次是在什么时候在温度步骤中进行处理的?
在与其他工程师的讨论中,我们确定5分钟是一个批次在温度步骤中处理的时间长度。 因此,应使用批次完成时间戳之前 5 分钟的温度数据来与批次的效力相关联。
现在我们有了开始数据准备过程所需的信息。
笔记:此示例从已使用正确的数据类型和建模类型正确编码的日期时间开始。 如果您希望连接正常工作,这是非常重要的一步。 如果您需要复习如何使用日期、时间和日期时间,请跳至本博客文章的附录。
视频演示
快来加入吧! 下载下面附加的两个数据集并继续操作。 如果您还没有 JMP,您可以下载 30 天试用版。
步骤回顾
- 确定与产品相关的传感器数据读数范围。
- 我的流程如何影响终点指标?
- 对于每个过程,与最终产品相关的传感器读数的时间范围是多少?
- 对于每个过程,我想要与最终产品关联的传感器读数的时间范围是多少?
- 在数据集中创建一个列,其中包含定义终点指标的终点指标第一的每条相关记录的时间戳。
- 通过使用公式列和成品时间戳(或其他参考时间戳,如果不可用)来执行此操作。
- 您可能还需要定义最后一个相关时间戳。
- 使用表 > JMP 查询生成器将包含端点指标的表连接到传感器数据。
- 需要编辑连接条件以包含两个条件:一个将传感器时间戳与成品表的时间戳进行比较,另一个将传感器时间戳与第二步中计算的第一个时间戳进行比较。
- 使用表 > 摘要汇总(即平均)连接表中的传感器指标。
- 选择传感器指标,然后选择所需的统计数据。
- 按所有其他列分组。
- 使用图形生成器或用 X 拟合 Y 查看效力和平均温度之间的关系。
- 哪里的效力最高?
- 这可以告诉您在哪里设置温度工作范围?
- 考虑使用建模技术,以便您也可以合并所有其他流程输入。
请对此博文发表评论,并让我知道您是否跟进。 我想知道您是否认为这些说明很清楚,如果不清晰,我可以澄清什么。另外,您还遇到哪些情况此处未解决?
附录
日期、时间和日期时间的审查
让我们快速回顾一下这种类型的数据,因为如果您希望正确连接数据,那么在所有数据表中获得正确的数据类型和建模类型非常重要。 分析软件以参考日期为单位存储日期、时间和日期时间(以秒为单位)。 JMP 将日期、时间和日期时间存储为自 1904 年 1 月 1 日起的秒数。 还有另一篇很棒的博客文章使用日期、时间、日期时间和持续时间如果你想更深入地讨论这个话题。
如果您想使用这种类型的数据(绘制图表、减去日期、通过日期连接),您需要确保日期/时间/日期时间的格式设置为数据类型 = 数字且建模类型 = 连续。 导入数据时,请确保这样做。 对于特殊类型的日期时间格式,您可能需要应用自定义导入格式让 JMP 知道它是日期时间。
将数据格式化为数字和连续后,您将看到数据以秒为单位表示。 这对你来说可能看起来很奇怪,但它是正确的。
应用格式可以使数据对您和其他人来说看起来易于理解。 您可以在“列信息”中选择日期、时间和持续时间格式(右键单击列标题 > 列信息 > 格式)。 日期时间(时间戳)位于“时间”菜单中(图 5)。
Figure 5. Format options for Dates, Times and Durations for a column.Figure 5. Format options for Dates, Times and Durations for a column.Figure 5. Format options for Dates, Times and Durations for a column.Figure 5. Format options for Dates, Times and Durations for a column.图 5. 列的日期、时间和持续时间的格式选项。
在旁边
如果您想通过日期时间将两个数据表连接在一起,请确保两个表中的日期时间列具有执行此操作所需的详细信息级别。 详细程度由源数据决定。 该格式不会改变 JMP 所识别的数据粒度;它只是改变了我们在细胞中可见的粒度。
让我们考虑两种情况:
- 如果您的数据仅具有日期级别的粒度(无时间),则应用时间戳格式(例如 m/d/yh:m:s)将显示 m/d/y,然后显示该时间的 12:00:00 AM对于所有记录。 您的源值中没有时间详细信息,因此您无法比较同一天内的时间。
- 如果您的数据具有日期时间级别的详细信息,则应用日期格式(例如仅月/日/年)将在每个单元格中显示月/日/年;但是,底层粒度将保留(图 4)。
Figure 6. Timestamp columns with different formats but the same granularity.Figure 6. Timestamp columns with different formats but the same granularity.Figure 6. Timestamp columns with different formats but the same granularity.Figure 6. Timestamp columns with different formats but the same granularity.图 6. 格式不同但粒度相同的时间戳列。
对比图 7 中的两列(时间戳和日期)。 两者应用相同的格式。 但是,时间戳具有日期所没有的粒度,您可以在数据表的标题图中看到这一点。
Figure 7. Timestamp and Date have the same format but different levels of granularity.Figure 7. Timestamp and Date have the same format but different levels of granularity.Figure 7. Timestamp and Date have the same format but different levels of granularity.Figure 7. Timestamp and Date have the same format but different levels of granularity.图 7. 时间戳和日期具有相同的格式,但粒度级别不同。
不错的视频。 第二个视频中对查询生成器的精彩介绍!