티스토리 뷰

 

<결과>

24.0
27

<소스 코드>

def Test_DataFrame2():
    from pandas import DataFrame
    data11 = {
        'a1': 11,
        'b1': "12"
    }
    data12 = {
        'a1': 21,
        'b1': "22"
    }
    data13 = {
        'a1': 31,
        'b1': "32"
    }
    data14 = {
        'a1': 41,
        'b1': "42"
    }

    dataDF = DataFrame()
    dataDF = dataDF.append(data11, ignore_index=True)
    dataDF = dataDF.append(data12, ignore_index=True)
    dataDF = dataDF.append(data13, ignore_index=True)
    dataDF = dataDF.append(data14, ignore_index=True)
    index11 = dataDF.index[dataDF['b1']=="22"].tolist()
    if index11:
        dataDF.loc[index11[0], 'a1'] += 3
        value11 = dataDF.loc[index11[0], 'a1']
        print(value11)
        value12 = int(dataDF.loc[index11[0], 'b1']) + 5
        print(value12)

    print(data14)
반응형
반응형
250x250
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/02   »
1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28
글 보관함