Skip to content
The Chat Archive
gpt-3.5-turbo-0301· OpenAI WildChat-4.8M (AI2)

Write a python code of the following: I have an excel file called 'NUR Procedural…

  1. User

    Write a python code of the following:

    I have an excel file called 'NUR Procedural 012022.csv' which is located in the same directory as the python or 'D:\Python\Python310\myenv\Scripts'. In this CSV there is the following header from column A to Column T.

    Filter Column F - Header 'Document Item Name' to filter only include the following values SGH_NUR_AEC_PADSSConsciousness SGH_NUR_AEC_PADSSConsciousness_NUM SGH_NUR_AEC_PADSSActivityLevel SGH_NUR_AEC_PADSSActivityLevel_NUM SGH_NUR_AEC_PADSSRespiration SGH_NUR_AEC_PADSSRespiration_NUM SGH_NUR_AEC_PADSSO2Sat SGH_NUR_AEC_PADSSO2Sat_NUM SGH_NUR_AEC_PADSSPulseRate SGH_NUR_AEC_PADSSPulseRate_NUM SGH_NUR_AEC_PADSSCirculationBP SGH_NUR_AEC_PADSSCirculationBP_NUM SGH_NUR_AEC_PADSSTtlScore_NUM

    With each unique 'Case No' in Column A, there is at least contain a value in column K - 'Value Text' for the following 6 fields. SGH_NUR_AEC_PADSSO2Sat_NUM SGH_NUR_AEC_PADSSPulserate_NUM SGH_NUR_AEC_PADSSRespiration_NUM SGH_NUR_AEC_PADSSActivityLevel_NUM SGH_NUR_AEC_PADSSCirculationBP_NUM SGH_NUR_AEC_PADSSConsciousness_NUM

    For each unique 'Case No', if either of this 6 field where the 'value text' is empty cell, it consider a 'Missed Set'.

    Print the total number of counts with the complete set. Print the total number of counts with incomplete set.

  2. Assistant

    import pandas as pd

    read the excel file

    df = pd.read_csv('NUR Procedural 012022.csv')

    filter the desired columns

    columns_to_keep = ['Case No', 'Document Item Name', 'Value Text'] df = df[columns_to_keep]

    filter the rows based on Document Item Name

    document_item_names = ['SGH_NUR_AEC_PADSSConsciousness', 'SGH_NUR_AEC_PADSSConsciousness_NUM', 'SGH_NUR_AEC_PADSSActivityLevel', 'SGH_NUR_AEC_PADSSActivityLevel_NUM', 'SGH_NUR_AEC_PADSSRespiration', 'SGH_NUR_AEC_PADSSRespiration_NUM', 'SGH_NUR_AEC_PADSSO2Sat', 'SGH_NUR_AEC_PADSSO2Sat_NUM', 'SGH_NUR_AEC_PADSSPulseRate', 'SGH_NUR_AEC_PADSSPulseRate_NUM', 'SGH_NUR_AEC_PADSSCirculationBP', 'SGH_NUR_AEC_PADSSCirculationBP_NUM', 'SGH_NUR_AEC_PADSSTtlScore_NUM'] df = df[df['Document Item Name'].isin(document_item_names)]

    iterate through each unique Case No

    complete_set_count = 0 incomplete_set_count = 0 for case_no in df['Case No'].unique(): sub_df = df[df['Case No']==case_no] # check if all 6 fields have non-empty value text is_complete_set = all(sub_df[sub_df['Document Item Name'].str.contains('_NUM')]['Value Text'].notnull()) if is_complete_set: complete_set_count += 1 else: incomplete_set_count += 1

    print(f'Total number of cases with complete set: {complete_set_count}') print(f'Total number of cases with incomplete set: {incomplete_set_count}')