I need to split a dataframe in spark using scala based on a give ratio. This should be done on the sorted version of dataframe by a particular column named ts. The first ratio is used for a training and the lats part is going to be used for validation.
val dataframe=//a sample dataframe
val trainRatio=0.8;
val training=//dataframe.rdd.orderBy("ts")
val test=//
Can someone give me any hint how to do that?