Skip to content

Commit

Permalink
Refactor: s_rank (#772)
Browse files Browse the repository at this point in the history
  • Loading branch information
cristineguadelupe authored Dec 14, 2023
1 parent b80fd1a commit c631fad
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions native/explorer/src/series.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1359,25 +1359,17 @@ pub fn s_rank(
seed: Option<u64>,
) -> Result<ExSeries, ExplorerError> {
let rank_method = parse_rank_method_options(method, descending);
let rank_data_type = match rank_method.method {
RankMethod::Average => DataType::Float64,
_ => DataType::Int64,
};

match rank_method.method {
RankMethod::Average => {
let new_s = series
.rank(rank_method, seed)
.cast(&DataType::Float64)?
.into_series();

Ok(ExSeries::new(new_s))
}
_ => {
let new_s = series
.rank(rank_method, seed)
.cast(&DataType::Int64)?
.into_series();
let new_s = series
.rank(rank_method, seed)
.cast(&rank_data_type)?
.into_series();

Ok(ExSeries::new(new_s))
}
}
Ok(ExSeries::new(new_s))
}

pub fn parse_rank_method_options(strategy: ExRankMethod, descending: bool) -> RankOptions {
Expand Down

0 comments on commit c631fad

Please sign in to comment.