해결된 질문
작성
·
808
·
수정됨
답변 2
1
Hello this is Gulshan Negi
Well, I search about it on internet and in short I can say.
The main difference between df.sum() and sum(df) is their usage and the objects they operate on.
df.sum() is a pandas DataFrame method that calculates the sum of each column by default. It returns a new pandas Series object containing the column-wise sums. It provides flexibility in specifying the axis of summation and handling missing or non-numeric values appropriately.
On the other hand, sum(df) is a built-in Python function that attempts to iterate over the columns of a data frame and calculate their sum. However, this usage might not work as intended because DataFrames are not inherently iterable in the same way as Python lists or tuples.
Thanks
0
sum(df) 파이썬 기본 함수
df.sum() 판다스 함수(정확히는 메소드)
입니다 💪
숫자외에 문자 컬럼이 있을 경우 판다스 버전이 업데이트되면서 워닝이 발생해요
df.sum(numeric_only=True)로 설정해주세요