티스토리 뷰

SWDesk

[Python] Testing ... DataFrame

inhae 2022. 5. 31. 11:15

 

  • DataFrame에서 특정 값을 갖는 행 찾기
  • 특정 값을 갖는 행 삭제
def Test_DataFrame11():
    data1 = {
        'aa1': 11,
        'aa2': 21,
        'aa3': 31
    }
    data2 = {
        'aa1': 12,
        'aa2': 22,
        'aa3': 32
    }
    data3 = {
        'aa1': 13,
        'aa2': 23,
        'aa3': 33
    }

    dataDF = DataFrame([data1])
    dataDF = dataDF.append(data2, ignore_index=True)
    dataDF = dataDF.append(data3, ignore_index=True)

    #print(dataDF)

    index1 = dataDF[dataDF['aa1']==13].index
    #print(index1)

    dataDF = dataDF.drop(index1, axis=0)
    print(dataDF)
반응형