1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] What is the most efficient way in Pandas to search for dates entries in a dataframe...

Discussão em 'Python' iniciado por Stack, Outubro 3, 2024 às 14:02.

  1. Stack

    Stack Membro Participativo

    I am trying to determine whether a given set of obstetrics patients have recieved their flu shots in the current flu season.

    That is, I have essentially three dataframes:

    >>> edds
    name expected_delivery_date
    0 Susan 2024-12-01
    1 Susan 2023-10-01
    2 Marie 2024-10-15

    >>> flu_shots
    name flu_shot_date
    0 Susan 2023-09-01
    1 Marie 2022-09-01


    >>> flu_season_begin_dates
    0 2024-09-01
    1 2023-09-01
    2 2022-09-01
    3 2021-09-01


    What is the most efficient way to identify which women got a flu shot (a) before their due date but (b) on or after the start of the most recent flu season?

    >>> got_flu_shot
    name expected_delivery_date got_required_flu_shot
    0 Susan 2024-12-01 False
    1 Susan 2023-10-01 True
    2 Marie 2023-10-01 True



    I can think of going row-by-row by (name, expected_delivery_date) and searching for the "most recent flu shot before the delivery" and "most recent flu season start date" but that feels inherently inefficient.

    Continue reading...

Compartilhe esta Página