為什麼要按日期時間連接數據集?
科學家和工程師面臨的常見數據準備挑戰之一是按日期、時間或日期時間(也稱為時間戳)匹配不同的數據集(圖 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. 時間戳和日期具有相同的格式,但粒度級別不同。
不錯的視頻。 第二個視頻中對查詢生成器的精彩介紹!