pandas ) 중복 데이터 처리 duplicated(), drop_duplicates()
duplicated() 중복 데이터 확인 요소를 검사하여 중복된 요소면 True 아니면 False를 반환한다. import pandas as pd df = pd.DataFrame({'c1': ['a','a','b','a','b'], 'c2': [1,1,1,2,2], 'c3': [1,1,2,2,2] }) print(df); print() # 중복 데이터 확인 : .duplicated() 중복된 데이터이면 True print(df.duplicated()) # 행단위의 중복 확인 print() print(df['c2'].duplicated()) # 열단위(Series)의 중복 확인 print() 실행결과 c1 c2 c3 0 a 1 1 1 a 1 1 2 b 1 2 3 a 2 2 4 b 2 2 0 False 1 ..
2022. 4. 4.
seaborn ) 한 개의 Figure에 여러 Axes 적용
FaceGrid() 행과 열에 데이터 별로 상관관계를 시각화해준다. import matplotlib.pyplot as plt import seaborn as sns # Seaborn 제공 데이터셋 가져오기 titanic = sns.load_dataset('titanic') # 스타일 테마 설정 (5가지: darkgrid, whitegrid, dark, white, ticks) sns.set_style('whitegrid') # 조건에 따라 그리드 나누기 g = sns.FacetGrid(data=titanic, col='who', row='survived',margin_titles=True) # 그래프 적용하기 g = g.map(plt.hist, 'age') pairplot() scatter, kde, h..
2022. 3. 30.
seaborn ) 막대 그래프
seaborn의 막대그래프는 기본적으로 오차범위를 계산하여 표시하여 준다. plt.figure(figsize=(5,4)) sns.barplot(x="sex",y="tip",data= tips) plt.show() 집단을 한 단계 더 나눠서 자세하게 시각화 할 수 있다. # 여러 열에서 집단 묶어서 세부 집단 시각화 하기 # hue 파라미터 추가 plt.figure(figsize=(6,4)) sns.barplot(x="sex",y="tip",hue="day", data=tips) plt.show() 오차막대가 보기 싫다면 ci=None # 오차막대 없애기 plt.figure(figsize=(6,4)) sns.barplot(x="sex",y="tip",hue="day", data=tips, ci=None) ..
2022. 3. 28.