Pandas_모아두기

기린이·2021년 5월 11일
0

모아두기🔧

목록 보기
5/39

pandas.core.groupby.DataFrameGroupBy.transform

공식문서
예제링크

temp_df['lag_1'] = temp_df.groupby(['id'])[TARGET].transform(lambda x: x.shift(1))

apply 함수 꿀

def test(x):
  if x =='저렴한': return 'cheap'
  elif x =='예쁜': return 'pretty'
  elif x == '아늑한': return 'comport'
  elif x == '빈티지': return 'vintage'
  elif x == '이국적/이색적': return 'exotic'
  elif x == '분위기좋은': return 'good_mood'
  elif x == '고급스러운': return 'Luxurious'
  elif x == '캐주얼한': return 'casual'
  elif x == '깔끔한': return 'clean'
  elif x == '조용한': return 'quiet'
  elif x == '감성적인': return 'emotional'
  elif x == '서민적인': return 'common'
  elif x == '시끌벅적한': return 'noisy'

df['feat_eng'] = df['feat10'].apply(test)
profile
중요한 것은 속력이 아니라 방향성

0개의 댓글