Conversation
…fset differences Adds two new F# module functions and corresponding C# extension methods for computing TimeSpan differences between consecutive DateTime and DateTimeOffset values in a series. - Series.diffDate: Series<'K, DateTime> -> Series<'K, TimeSpan> - Series.diffDateOffset: Series<'K, DateTimeOffset> -> Series<'K, TimeSpan> - SeriesExtensions.Diff overloads for C# consumers The existing Series.diff uses an inline type-constrained implementation that requires the subtraction operator to be homogeneous (T - T = T). DateTime - DateTime = TimeSpan is heterogeneous, so a separate implementation using shift + zipInto is required. Closes #565 Co-authored-by: Copilot <[email protected]>
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Adds
Series.diffDateandSeries.diffDateOffsetfunctions that compute theTimeSpandifference between consecutiveDateTime/DateTimeOffsetvalues in a series — addressing the feature request in #565.Motivation
The existing
Series.diffuses an F# inline type-constrained implementation requiring homogeneous subtraction (T - T = T).DateTime - DateTime = TimeSpanis heterogeneous, soSeries.diffcannot be used for timestamp series and would raise a runtime type error if attempted.Implementation
The new functions use
shift+zipIntointernally:For
offset = 1, this gives the elapsed time since the previous observation — useful for detecting periodicity, irregular intervals, gaps, etc.New API surface
Series.diffDate offset seriesseries.Diff(offset)Series<'K, TimeSpan>Series.diffDateOffset offset seriesseries.Diff(offset)Series<'K, TimeSpan>Usage example
Trade-offs
diffDate/diffDateOffset) mirrors the existingdiffnaming convention.diff, but the difference is negligible for typical use cases and the clarity is worth it.Test Status
Build: ✅
dotnet build src/Deedle/Deedle.fsproj -c Release— succeeded, 0 errors.Tests: ✅ 4 new tests added in
tests/Deedle.Tests/Series.fs; all pass. Full suite: 467 passing (1 pre-existing failure in "Can expand properties based on runtime type information" — unrelated to this PR).Note:
dotnet fake buildhas an infrastructure issue in this environment (FAKE TypeInitializationException); thedotnet build/dotnet testpaths were used instead.Closes #565