a = pd.Series([1,4,9,16,25])
b = pd.Series({'one' : 1, 'two' : 2, 'three' : 3, 'four' : 4})
#a:
#0 1
#1 4
#2 9
#3 16
#4 25
#dtype: int64
#b:
#one 1
#two 2
#three 3
#four 4
#dtype: int64
a[ a>a.median() ] # 자기 자신의 median(중앙값)보다 큰 값들만 가지고 와라
#3 16
#4 25
#dtype: int64
d = {"height" : [1,2,3,4], "weight":[30,40,50,60]}
df = pd.DataFrame(d)
# height weight
#0 1 30
#1 2 40
#2 3 50
#3 4 60
.read_csv()
# 동일 경로에 country_wise_latest.csv 파일 존재하면 :
# 현재경로 -> .
covid = pd.read_csv("./country_wise_latest.csv")
.head(n)
: 처음 n개의 데이터 참조.tail(n)
: 마지막 n개의 데이터를 참조df['column_name']
or df.column_name
※ column name에 공백이 들어가는 경우에는 앞에 방법을 택해야한다.
ex)
covid['WHO Region']
# Ok
covid.WHO Region
# Error
covid['New cases'] > 100
#True, True, False, .... True, True
covid[covid['New cases'] > 100]
#True값에 해당하는 데이터 가져오기
.loc[row, col]
.iloc[rowidx,colidx]
#Split
covid_by_region = covid['Confirmed'].groupby(by=covid['WHO Region'])
#Apply & combine
covid_by_region.sum()
#WHO Region
#Africa 723207
#Americas 8839286
#Eastern Mediterranean 1490744
#Europe 3299523
#South-East Asia 1835297
#Western Pacific 292428
#Name: Confirmed, dtype: int64