A
A
Alexey R2021-08-21 14:45:57
Python
Alexey R, 2021-08-21 14:45:57

Why does a part of the code not work in the script?

Good day to all. Colleagues ask you for help. Not how it does not reach me why the script does not work. The task is this. Once a month, 10 .xlsx files are exported from the system and assembled by the script into one large file. Then the dreary work with the filter begins. The main thing that is needed is to select the total number of people in accordance with the diagnoses, filter them by gender and select working age and non-working age for both men and women . It takes a huge amount of time. So I wrote a python script using pandas library. It works great. But the task has become more complicated because now I need to do the same in addition to the above, but select people who have been registered in the current month. That is, in addition to the general report, it is necessary to do the same for people who are newly registered. And this is where I got stuck. the script after line 66 does not see people. If you print print () and these are 69 and 71 lines, then this is clearly visible. Tell me what am I doing wrong?
https://pastebin.com/JvL51p8C
Sample script output:6120e76e29058370921204.png

for elem in gen_list:
    #Применяем фильтр к столбцу "Диагноз"
    df_1 = df.loc[df['Диагноз'].isin(elem)]
    #Создаём переменную с общим кол-вом отобранных пациентов по диагнозам I2....
    count_sexGL = len(df_1.index)
    print(df_1) - <b>Вот тут видно что скрипт читает .xlsx файл</b>
    df_new_pacient_on_year = df_1.loc[df_1['Дата взятия на учет'].isin(current_month)] - <b>здесь я хочу применить фильтр current_month который равен 07.2021 </b>
    print(df_new_pacient_on_year) - <b>Но при выводе я вижу только шапку</b>
    #count_sexGL_New = len(df_new_pacient_on_year.index)

6120f8b3f238b929632161.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey R, 2021-08-25
@Axeles

I did something similar to this df = df[df['date'].dt.year == 2017], namely df = df.loc[df['Date of registration'] == '07/01/2021'] and in this case, only 07/01/2021 is filtered to me, which is logical. And I need from 07/01/2021 to 07/31/2021. Until I figured out how. I will search further

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question