# crsp_full[crsp_full['permno']==90848]
# permno, 제대로된 lifetype, 현재 lifetype, 현재 life, 입력 crsp_trunc 레코드가 2개 존재함
# 30330, old-death, lifetype=old-death,life=2, first record date = sample_start
# 14252, shell, lifetype= normal, life=2, sample_start < first record date < sample_end
# 13010, shell, lifetype= normal, life=2, sample_start < first record date < sample_end
# 90848, shell, lifetype= normal, life=2, sample_start < first record date < sample_end
# Refco Inc, 90848
# permno, 제대로된 lifetype, 현재 lifetype, 현재 life, 이 경우는 입력 crsp_trunc 레코드가 1개만 존재함
# 15139, young-living, lifetype= shell, life=1, first record date = sample_end
# 16815
# crsp[crsp['permno']==14475] # Super Micro Computer (SMCI)라는 회사만 2019 상장폐지 후 2020년 재상장시 Permno (14475)가 유지되었다
result = crsp_full.groupby('lifetype')['permno'].nunique()
print(result)
import matplotlib.pyplot as plt
import seaborn as sns
# Group by permno to get unique records for plotting (1 row per permno)
permno_summary = (
crsp_full.sort_values("date")
.groupby("permno", as_index=False)
.first()
[["permno", "industry", "lifetype", "life", "state"]]
)