3
에 따라 :파이썬 팬더 다음과 같은 값으로 나는 DataFrame (DF)가 조건
Title
fintech_countries
US 60
UK 54
India 28
Australia 25
Germany 13
Singapore 11
Canada 10
내가와 '기타'로 값 < (25) 모든 국가를 추가하고, 보여주고 싶은 자신의 합 (34).
나는 다음과 같은 코드를 통해 국가에 대한 열 이름을 만든: 이제
df1 = df.rename_axis('fintech_countries').rename_axis("countries", axis="columns" , inplace=True)
countries Title
fintech_countries
US 60
UK 54
India 28
Australia 25
Germany 13
Singapore 11
Canada 10
, 나는에 유래에 다른 쿼리를 기반으로 다음과 같은 코드를 시도 :
df1.loc[df1['Title'] < 25, "countries"].sum()
을하지만 무엇입니까 다음 오류 :
KeyError: 'the label [countries] is not in the [columns]'
누군가 도움을 주시겠습니까? boolean indexing
에 의해
countries Title
fintech_countries
US 60
UK 54
India 28
Australia 25
Others 34
TIA setting with enlargement 및 필터링 loc
와
감사 톤! 효과가있다. – chhibbz