Skip to content

Commit

Permalink
Merge branch 'fix_visit_merging' of https://github.com/aphp/eds-scikit
Browse files Browse the repository at this point in the history
…into fix_visit_merging
  • Loading branch information
svittoz committed Apr 17, 2024
2 parents a57b167 + aee1bc0 commit 3569ca3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Changelog

## Unreleased
### Added
- sort_values_first_koalas function fo perform correctly sort_values(...).first() wehn using koalas dataframe

### Fixed
- merge_visit sort_values(...).first() issue is corrected

## v0.1.7 (2024-04-12)
### Changed
Expand Down
21 changes: 20 additions & 1 deletion eds_scikit/utils/sort_first_koalas.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
def sort_values_first_koalas(dataframe, by_cols, cols, ascending=True):
from eds_scikit.utils.typing import DataFrame
from typing import List

def sort_values_first_koalas(dataframe : DataFrame , by_cols : List[str], cols : List[str], ascending : bool = True) -> DataFrame:
"""Replacement for dataframe.sort_values(cols).groupby(by_cols).first()
To get a deterministic first, provide an id column of your dataframe as the last element of cols.
Parameters
----------
dataframe : DataFrame
by_cols : List[str]
cols : List[str]
ascending : bool, optional
Returns
-------
DataFrame
"""
for col in cols:
dataframe_min_max = dataframe.groupby(by_cols, as_index=False)[col]
dataframe_min_max = (
Expand Down

0 comments on commit 3569ca3

Please sign in to comment.