Чтение файла Excel: IndexError: одиночный позиционный индексатор выходит за пределы ⇐ Python
-
Anonymous
Чтение файла Excel: IndexError: одиночный позиционный индексатор выходит за пределы
I want to filter data in an Excel file based on patient number, message type, and test level, and then calculate the average of the lists in each cell of the 'RPS' column. However, I keep encountering an error.
enter image description here
import pandas as pd # Verilerinizi içeren Excel dosyasını okuyun df = pd.read_excel("C:/Users/bastu/busra_hoca/patient3-4/dot2.xlsx") hasta_listesi = [1, 2, 3, 4, 5, 6] tip_listesi = ["C1", "C2", "C3", "C4"] test_levels = [0, 1, 2, 3, "n1", "n2"] result = [] for hasta in hasta_listesi: for tip in tip_listesi: for test_level in test_levels: # Filtreleme işlemi filtre = (df['Patient'] == hasta) & (df['Message'] == tip) & (df['Test Levet'] == test_level) # filtre = (df['Hasta'] == hasta) & (df['Mesaj'] == tip) & (df['Test Level'] == test_level) filtrelenmis_veri = df[filtre] index_liste = filtrelenmis_veri.index.tolist() toplam = 0 for i in list(range(len(index_liste))): toplam += filtrelenmis_veri["RPS"].iloc[index_liste] result.append({"Hasta": hasta, "Elektrot": tip, "Test Seviyesi": test_level, "Toplam": toplam, "İndex Len": len(index_liste)})
Источник: https://stackoverflow.com/questions/780 ... -of-bounds
I want to filter data in an Excel file based on patient number, message type, and test level, and then calculate the average of the lists in each cell of the 'RPS' column. However, I keep encountering an error.
enter image description here
import pandas as pd # Verilerinizi içeren Excel dosyasını okuyun df = pd.read_excel("C:/Users/bastu/busra_hoca/patient3-4/dot2.xlsx") hasta_listesi = [1, 2, 3, 4, 5, 6] tip_listesi = ["C1", "C2", "C3", "C4"] test_levels = [0, 1, 2, 3, "n1", "n2"] result = [] for hasta in hasta_listesi: for tip in tip_listesi: for test_level in test_levels: # Filtreleme işlemi filtre = (df['Patient'] == hasta) & (df['Message'] == tip) & (df['Test Levet'] == test_level) # filtre = (df['Hasta'] == hasta) & (df['Mesaj'] == tip) & (df['Test Level'] == test_level) filtrelenmis_veri = df[filtre] index_liste = filtrelenmis_veri.index.tolist() toplam = 0 for i in list(range(len(index_liste))): toplam += filtrelenmis_veri["RPS"].iloc[index_liste] result.append({"Hasta": hasta, "Elektrot": tip, "Test Seviyesi": test_level, "Toplam": toplam, "İndex Len": len(index_liste)})
Источник: https://stackoverflow.com/questions/780 ... -of-bounds