Skip to content

Instantly share code, notes, and snippets.

@allieus
Created July 15, 2020 13:37
Show Gist options
  • Save allieus/16136f2e8ad4ab941db75509f90a9057 to your computer and use it in GitHub Desktop.
Save allieus/16136f2e8ad4ab941db75509f90a9057 to your computer and use it in GitHub Desktop.
apply 시에 예외가 발생하면, ???

실행결과

Series([], dtype: float64)

빈 DataFrame에는 빈 Series를 반환하며, 채워져있는 DataFrame에서는 ZeroDivisionError 예외가 발생합니다.

import pandas as pd
df = pd.DataFrame()
def fn(row):
1/0
print(repr(df.apply(fn, axis="columns").sum()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment