-
카테고리
-
세부 분야
자격증 (데이터 사이언스)
-
해결 여부
해결됨
df.sum() 과 sum(df) 차이가 뭔가요?
23.06.20 23:32 작성 23.06.20 23:35 수정 조회수 619
0
df.sum() 과 sum(df) 차이가 무엇인지 질문드립니다.
답변을 작성해보세요.
1
negigulshan903
2023.06.21
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
퇴근후딴짓
지식공유자2023.06.21
sum(df) 파이썬 기본 함수
df.sum() 판다스 함수(정확히는 메소드)
입니다 💪
숫자외에 문자 컬럼이 있을 경우 판다스 버전이 업데이트되면서 워닝이 발생해요
df.sum(numeric_only=True)로 설정해주세요
답변 2