[Section0] 나만의 사전

Kyungtaek Oh·2022년 6월 3일

AI Bootcamp

목록 보기
1/15
post-thumbnail

Data 수집/탐색/정제에 필요한 기본 함수 저장소

로컬 데이터 코랩으로 불러오기

from google.colab import files
files.upload()

csv 데이터 불러오기

df = pd.read_csv('data.csv', index_col = 0).dropna(axis = 1)

URL = "https://ds-lecture-data.s3.ap-northeast2.amazonaws.com/seoul_tree/seoul_tree.txt"
df = pd.read_csv(URL, sep='\t')

melt

wide format을 tidy format으로 변환
https://pandas.pydata.org/docs/reference/api/pandas.melt.html

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

pd.melt(df1, id_vars = 'index', var_name='variable', value_name='value')

pivot_table (melt의 반대)

tidy format을 wide format으로 반환

merge

df1.merge(df2, how='left', on=['key1', 'key2'])

astype

df['영업이익(발표기준)'] = df['영업이익(발표기준)'].astype('int')

profile
Studying for Data Analysis, Data Engineering & Data Science

0개의 댓글