admin管理员组文章数量:1122826
I have a barologger pressure time series that takes a reading every 15 minutes and a CT2X pressure time series that takes a measurement every 5 minutes. Unfortunately the time series is shifted and they don't align correctly. How can I filter my CT2X time series data so that it matches the time series of the barologger? How could I take an average of the three closest CT2X readings around the barologger time?
I have listed a picture "sample series columns" that ultimately shows what I wish to obtain.
I've tried the index-match tool in excel but I don't think I've used it correctly or if it can be done with this data.
I have a barologger pressure time series that takes a reading every 15 minutes and a CT2X pressure time series that takes a measurement every 5 minutes. Unfortunately the time series is shifted and they don't align correctly. How can I filter my CT2X time series data so that it matches the time series of the barologger? How could I take an average of the three closest CT2X readings around the barologger time?
I have listed a picture "sample series columns" that ultimately shows what I wish to obtain.
I've tried the index-match tool in excel but I don't think I've used it correctly or if it can be done with this data.
Share Improve this question edited Nov 22, 2024 at 21:38 Ron Rosenfeld 60k7 gold badges32 silver badges65 bronze badges asked Nov 22, 2024 at 20:22 Will MacKenzieWill MacKenzie 254 bronze badges 3 |1 Answer
Reset to default 0Since you did not show averages as a part of what you expect for results, I chose to return a single closest value by aligning the values by
- Determine the duration between a
Barologger Date/Time
and each of theCT2X Date/Time
entries. - Set a threshold for the maximum duration allowable.
- I chose two (2) minutes.
- Line up the appropriate entries.
I added a line and some information to the data you provided:
This can be accomplished using Power Query, available in Windows Excel 2010+ and Excel 365 (Windows or Mac)
To use Power Query
- Select some cell in your Data Table
Data => Get&Transform => from Table/Range
- When the PQ Editor opens:
Home => Advanced Editor
- Make note of the Table Name in Line 2
- Paste the M Code below in place of what you see
- Change the Table name in line 2 back to what was generated originally.
- Read the comments and explore the
Applied Steps
to understand the algorithm
M-Code
Edited to account for more rows in the last two columns than the first two
let
Source = Excel.CurrentWorkbook(){[Name="Table3"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Barologger DateTime (24hr)", type datetime}, {"Barologger LEVEL (cm)", type number}, {"CT2X Date / Time (24 hour)", type datetime}, {"CT2X Pressure (psi)", type number}}),
//Split the tables
Barologger = Table.Buffer(Table.SelectColumns(#"Changed Type",List.Range(Table.ColumnNames(#"Changed Type"),0,2))),
CT2X = Table.Buffer(Table.SelectColumns(#"Changed Type", List.Skip(Table.ColumnNames(#"Changed Type"),2))),
//Find the matching rows
#"Matched CT2X" = Table.Buffer(Table.AddColumn(Barologger, "Match CT2X",(r)=>
let
//generate a list of differences between each of the times
difs = List.TransformMany(
CT2X[#"CT2X Date / Time (24 hour)"],
each {_ -r[#"Barologger DateTime (24hr)"]},
(a,b)=> Number.Abs(Number.From(b))),
//determine the row numbers with the matching min times, using 2 minutes (2/1440) as the threshold
pos = if List.Min(difs) < 2/1440
then List.PositionOf(difs,List.Min(difs))
else null
in pos)),
#"Matching CT2X" = Table.TransformColumns(#"Matched CT2X",{"Match CT2X",
each CT2X{_},type [#"CT2X Date / Time (24 hour)"=datetime, #"CT2X Pressure (psi)"=number]}),
#"Removed Errors" = Table.RemoveRowsWithErrors(#"Matching CT2X", {"Match CT2X"}),
#"Expanded Match CT2X" = Table.ExpandRecordColumn(#"Removed Errors", "Match CT2X", {"CT2X Date / Time (24 hour)", "CT2X Pressure (psi)"})
in
#"Expanded Match CT2X"
Either method gives the following results from the data I posted:
本文标签: datetimeHow can I align high frequency time series data in microsoft excelStack Overflow
版权声明:本文标题:datetime - How can I align high frequency time series data in microsoft excel - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736301048a1931041.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
CT2X
readings around the barologger time". Also, your result table is showing aCT2X
reading (12:36
) that does not exist in your data table. Please clarify both of these discrepancies. – Ron Rosenfeld Commented Nov 22, 2024 at 23:06