Skip to content
Browse files

Functional replace of a column series in frame.

  • Loading branch information...
1 parent f295a1d commit b0aa5089da94fba51a508d86168c4d352a03dd4c @RayRacine committed
Showing with 9 additions and 0 deletions.
  1. +9 −0 rpr/frame/frame.rkt
View
9 rpr/frame/frame.rkt
@@ -24,6 +24,7 @@
[frame-rename (Frame Label Label -> Frame)]
[frame-drop (Frame Label -> Frame)]
[frame-explode (Frame [#:project LabelProjection] -> Columns)]
+ [frame-replace (Frame Column -> Frame)]
[frame-extend (Frame (U Column Columns Frame) -> Frame)]
[frame-description (Frame [#:project LabelProjection] -> FrameDescription)]
[show-frame-description (FrameDescription -> Void)])
@@ -230,6 +231,14 @@
(car l-s))
project)))
+(: frame-replace (Frame Column -> Frame))
+(define (frame-replace frame new-col)
+ (define name (column-heading new-col))
+ (new-frame (for/list ([col (frame-explode frame)])
+ (if (eq? name (column-heading col))
+ new-col
+ col))))
+
(: frame-extend (Frame (U Column Columns Frame) -> Frame))
(define (frame-extend frame cols)
(cond

0 comments on commit b0aa508

Please sign in to comment.
Something went wrong with that request. Please try again.