python

파이썬으로 HTML 문서 분석:설치해야할 패키지(pip install package-name)1) beautifulsoup4: HTML 요소들을 분석하는 패키지2) html5lib: HTML 문서를 parsing(분석)3) requests: HTTP 요청(request)을 보내고, 서버로부터 응답(response)을 받는 기능을 담당. web01.html----------------------------------------------------------------------------------------------------------------- 처음 작성하는 HTML HTML: HyperText Markup Language 여기는 paragraph입니다. 여기는 division입니다. 다음 카카..
import numpy as npimport pandas as pd np.random.seed(1)df = pd.DataFrame({ 'pop': np.random.randint(1, 10, 4), # 1~ 10 범위의 난수 4개 'income': np.random.randint(1, 10, 4), # 1~10 범위의 난수 4개 }, index=['a', 'b', 'c', 'd'])print(df) pop incomea 6 1b 9 2c 6 8d 1 7 # agg(aggregate): DataFrame의 축(axis)을 기준으로 통계량을 집계(aggregate)하기 위한 함수# 통계량(statistics): 합계(sum), 평균(mean), 분산(var), 표준편차(std),# 최솟값(min), 최댓값(..
import numpy as npimport pandas as pd def squares(x): return x ** 2 def doubles(x): return x * 2 result1, result2 = squares(3), doubles(3)print(result1, result2)9 6 array = np.array([1, 2, 3])result1 = squares(array) # np.array ** 2result2 = doubles(array) # np.array * 2print(result1, result2)[1 4 9] [2 4 6] df = pd.DataFrame({'a': [1, 2, 3],'b': [4, 5, 6]})print(df)print(squares(df)) a b0 1 41 ..
import numpy as npimport pandas as pd # 데이터 프레임 생성np.random.seed(1)df = pd.DataFrame({'key1': ['a', 'a', 'b', 'b', 'a'],'key2': ['one', 'two', 'one', 'two', 'one'],'data1': np.random.randint(0, 10, 5),'data2': np.random.randint(0, 10, 5)})print(df) key1 key2 data1 data20 a one 5 01 a two 8 12 b one 9 73 b two 5 64 a one 0 9 grouped1 = df.groupby(by='key1')print(grouped1) # DataFrameGroupBy 객체 - ..
Codezoy
'python' 태그의 글 목록 (5 Page)