목록Programming (97)
59doit
함수 사용 (1) 함수 도움말 help(함수명) help(함수명, package="패키지명") help(rlm, package="MASS") ex ) 함수 파라미터 확인 max 함수의 파라미터 확인 args(max) max(10, 20, NA, 30) ex ) example()함수 사용 example()함수: R에서 제공하는 기본 함수의 사용예제 / example(함수명) example(seq) example(max) seq()함수: 일반 시퀀스 생성 ex ) mean()함수 사용 mean()함수: 평균 계산 example(mean) mean(10:20) x Open File

working directory 설정 getwd() setwd() 변수 변수이름 명명방법 (1) 변수 이름 명명 규칙 in R 1) 첫 글자는 영문자로 시작 2) 2 번째 단어부터는 숫자, _, . 등을 사용 가능 3) 대문자와 소문자를 구별한다. 4) 변수의 이름은 의미에 맞도록 작성한다. 5) 한 번 정의된 변수는 재사용이 가능하고, 가장 최근의 값이 저장되어 있다. 6) Camel case 선호 ex )'변수.멤버' 형식의 변수 선언 goods.code
import numpy as np import pandas as pd ex1 s = pd.Series(np.random.randn(6)) s[::2] = np.nan s s.fillna(s.mean()) states = ['Ohio', 'New York', 'Vermont', 'Florida', 'Oregon', 'Nevada', 'California', 'Idaho'] group_key=['East']*4+['West']*4 data=pd.Series(np.random.randn(8),index=states) data data[['Vermont','Nevada','Idaho']] = np.nan data data.groupby(group_key).mean() fill_mean = lambda g: g...
apply ▷ def top(df, n=5, column='tip_pct'): return df.sort_values(by=column)[-n:] top(tips, n=6) # # total_bill tip smoker day time size tip_pct # 109 14.31 4.00 Yes Sat Dinner 2 0.279525 # 183 23.17 6.50 Yes Sun Dinner 4 0.280535 # 232 11.61 3.39 No Sat Dinner 2 0.291990 # 67 3.07 1.00 Yes Sat Dinner 1 0.325733 # 178 9.60 4.00 Yes Sun Dinner 2 0.416667 # 172 7.25 5.15 Yes Sun Dinner 2 0.710345 ..