코오딩공부하고
DataFrame 과 Numpy 비교
포토리소그래퍼
2020. 7. 16. 15:14
헷갈려서 정리
DataFrame | Numpy | |
타입보기 | .dtypes | .dtype |
쉐입보기 | .shape | .shape |
DataFrame -> Numpy 변경 | df.values , df.to_numpy() | |
슬라이싱 | .iloc[몇이상:몇미만,몇이상:몇미만] .loc[문자이상:문자이하,문자이상,문자이하] |
[몇이상:몇미만, 몇이상:몇미만] |
column으로 slicing | df['column명'] | 애초에 컬럼이름같은거 안나옴 [[a,b,c][d,e,f]] |
조건 index 만든후 슬라이싱 | (obj_arr = df.dtypes=='object' 이런식으로 주어질 때) df.iloc[:,obj_arr.array] |
(obj_arr = df_np[:,0] >=5 이런식으로 주어질 때) df_np[obj_arr,:] |
합치기 | pd.concat([df1,df2,df3] | np.concatenate((np1,np2)) |
결측치 | df.isnul() | np.isnan(np1) |
통계 | .mean() | .mean() |