AI 부트캠프 3일차

Section1 Note 03 : Data Manipulation

학습목표

  1. concat / merge
  2. tidy 데이터
  3. melt : wide -> tidy
    pivot_table : tidy -> wide

Warm-up : pandas trick

https://nbviewer.jupyter.org/github/justmarkham/pandas-videos/blob/master/top_25_pandas_tricks.ipynb

Data Manipulation

concat

pd.concat([df1,df2])

merge

공통된 부분 합치기

df1.merge(df2, how = ' ', on = ' ')

isin

df_subset[df_subset[' '].isin([' '])]

group_by

df_subset.groupby(' '). .mean()

melt : wide -> tidy

tidy1 = tidy1.melt(id_vars = 'index', value_vars = ['A', 'B'])

pivot_table : tidy -> wide

wide = tidy1.pivot_table(index = 'row', columns = 'column', values = 'value')

tidy data : 시각화에 유리

import seaborn as sns
sns.catplot(x = 'row', y = 'value', col = 'column', kind = 'bar', data = tidy1, height = 2);

좋은 웹페이지 즐겨찾기