Skip to content

Commit

Permalink
Fail multi column operation if any column not found
Browse files Browse the repository at this point in the history
The logic for this was buggy. I don't know what it was even doing. Fixed it.
  • Loading branch information
mchav committed Jan 19, 2025
1 parent 13320b1 commit 6a9f403
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Data/DataFrame.hs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Data.DataFrame.Internal.Types as D
import Data.DataFrame.Internal.Function as D
import Data.DataFrame.Internal.Parsing as D
import Data.DataFrame.Internal.Column as D
import Data.DataFrame.Internal.DataFrame as D
import Data.DataFrame.Internal.DataFrame as D hiding (columnIndices, columns)
import Data.DataFrame.Internal.Row as D hiding (mkRowRep)
import Data.DataFrame.Errors as D
import Data.DataFrame.Operations.Core as D
Expand Down
2 changes: 1 addition & 1 deletion src/Data/DataFrame/Operations/Aggregation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ groupBy ::
DataFrame ->
DataFrame
groupBy names df
| not $ any (`elem` columnNames df) names = throw $ ColumnNotFoundException (T.pack $ show $ names L.\\ columnNames df) "groupBy" (columnNames df)
| any (`notElem` columnNames df) names = throw $ ColumnNotFoundException (T.pack $ show $ names L.\\ columnNames df) "groupBy" (columnNames df)
| otherwise = L.foldl' insertColumns initDf groupingColumns
where
-- Create a string representation of each row.
Expand Down
2 changes: 1 addition & 1 deletion src/Data/DataFrame/Operations/Sorting.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ sortBy ::
DataFrame ->
DataFrame
sortBy order names df
| not $ any (`elem` columnNames df) names = throw $ ColumnNotFoundException (T.pack $ show $ names L.\\ columnNames df) "sortBy" (columnNames df)
| any (`notElem` columnNames df) names = throw $ ColumnNotFoundException (T.pack $ show $ names L.\\ columnNames df) "sortBy" (columnNames df)
| otherwise = let
-- TODO: Remove the SortOrder defintion from operations so we can share it between here and internal and
-- we don't have to do this Bool mapping.
Expand Down
2 changes: 1 addition & 1 deletion src/Data/DataFrame/Operations/Subset.hs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ select ::
DataFrame
select cs df
| L.null cs = empty
| not $ any (`elem` columnNames df) cs = throw $ ColumnNotFoundException (T.pack $ show $ cs L.\\ columnNames df) "select" (columnNames df)
| any (`notElem` columnNames df) cs = throw $ ColumnNotFoundException (T.pack $ show $ cs L.\\ columnNames df) "select" (columnNames df)
| otherwise = L.foldl' addKeyValue empty cs
where
cIndexAssoc = M.toList $ columnIndices df
Expand Down

0 comments on commit 6a9f403

Please sign in to comment.