Conversation
…es missing (#516) Previously, Frame.filterRows, Frame.filterRowValues and Frame.Where all reconstructed the frame from rows (via fromRowsAndColumnKeys), which loses column type information when a column's values are all missing in the filtered result. The witness-value lookup falls back to obj() when Seq.tryPick returns None, giving ElementType = typeof<obj>. Fix: replace the row-reconstruction path with the same column-wise approach already used by filterRowsBy and realignRows: compute a Relocate command via IndexBuilder.Reindex, then apply VectorHelpers.transformColumn to each column vector. This preserves the vector's generic type parameter T regardless of how many values are missing. Added open Deedle.Vectors to FrameExtensions.fs so VectorConstruction.Return is in scope. Regression test: 'Filter rows preserves column types when all column values are missing' verifies that column types remain float after filtering to rows where a column contains only NaN. Co-authored-by: Copilot <[email protected]>
This was referenced Mar 9, 2026
…rves-columntypes-18b8652a98367afb
…rves-columntypes-18b8652a98367afb
…rves-columntypes-18b8652a98367afb
…rves-columntypes-18b8652a98367afb
dsyme
approved these changes
Mar 9, 2026
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.
Fixes the bug reported in #516 where
frame.ColumnTypesincorrectly changes toSystem.Objectafter filtering rows when the resulting column contains only missing values.Root Cause
Frame.filterRows,Frame.filterRowValues, andFrame.Whereall previously reconstructed the frame from rows (viaFrameUtils.fromRowsAndColumnKeys). That function uses a "witness value" to determine the column type — it picks any non-missing value from the column to drive type dispatch:When all values in a column are missing after filtering,
Seq.tryPickreturnsNone, the fallback becomesobj(), and the resulting column vector hasElementType = typeof(obj). Henceframe.ColumnTypesreportsSystem.Objectinstead of the original type.Fix
Replace the row-reconstruction path in
filterRows,filterRowValues, and bothWhereoverloads with the same column-wise approach already used byfilterRowsByandrealignRows:IndexBuilder.Reindexto produce aRelocatevector command that maps the new row addresses back to the original ones.VectorHelpers.transformColumnto each column vector — this preserves the generic type parameter'Tof each column regardless of how many values are missing.Also adds
open Deedle.VectorstoFrameExtensions.fssoVectorConstruction.Returnis in scope.Behaviour preserved
Test
New regression test
Filter rows preserves column types when all column values are missingintests/Deedle.Tests/Frame.fsverifies that columnElementTyperemainsfloatafter filtering to rows where a column contains onlyNaN(missing) values.Test Status
dotnet build src/Deedle/Deedle.fsproj -c Release— 0 errorsdotnet test tests/Deedle.Tests/Deedle.Tests.fsproj -c Release— 465 / 465 passedCloses #516