일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
- Google Excel
- Github
- PANDAS
- array
- Kotlin
- c#
- Java
- Mac
- dataframe
- SQL
- string
- Redshift
- Python
- matplotlib
- list
- google apps script
- 파이썬
- gas
- math
- Excel
- PySpark
- hive
- Tkinter
- numpy
- GIT
- django
- Apache
- Google Spreadsheet
- PostgreSQL
- Today
- Total
목록Python (384)
달나라 노트

import requests from bs4 import BeautifulSoup as bs URL = "https://www.naver.com" rq = requests.get(URL) soup = bs(rq.content, 'html.parser') print(soup) 어떤 Web 페이지의 HTML 코드를 가져오기 위해선 위처럼 requests와 bs4 libarary를 사용합니다. URL = "https://www.naver.com" rq = requests.get(URL) 위 부분은 정해진 URL에 대한 웹 자원을 요청하여 가져오는 역할을 합니다. soup = bs(rq.content, 'html.parser') print(soup) 그리고 BeautifulSoup의 기능을 사용합니다. 먼저 r..
Pandas에서 사용할 수 있는 window function 기능을 알아봅시다. import pandas as pd dict_test = { 'col1': [1, 1, 2, 2, 3, 3, 3, 4], 'col2': [1000, 1100, 2100, 2050, 3000, 3100, 3200, 4200], 'col3': ['a', 'b', 'a', 'c', 'a', 'a', 'd', 'e'] } df_test = pd.DataFrame(dict_test) # print(df_test) # print(type(df_test)) - Output col1 col2 col3 0 1 1000 a 1 1 1100 b 2 2 2100 a 3 2 2050 c 4 3 3000 a 5 3 3100 a 6 3 3200 d 7..
Python의 strip, lstrip, rstrip은 다음과 같은 기능을 가집니다. strip = 문자열의 양쪽 끝에 있는 어떤 텍스트를 제거합니다. lstrip = 문자열의 왼쪽 끝에 있는 어떤 텍스트를 제거합니다. rstrip = 문자열의 오른쪽 끝에 있는 어떤 텍스트를 제거합니다. str_test = ' abcde ' str_stripped = '[' + str_test.strip() + ']' str_lstripped = '[' + str_test.lstrip() + ']' str_rstripped = '[' + str_test.rstrip() + ']' print(str_stripped) print(str_lstripped) print(str_rstripped) - Output [abcde] ..
DataFrame의 fillna는 DataFrame에 존재하는 NaN값을 어떠한 값으로 채워줍니다. import pandas as pd import numpy as np dict_test = { 'col1': [1, 2, np.nan, 4, np.nan], 'col2': [np.nan, 'a', 'b', np.nan, 'z'], } df_test = pd.DataFrame(dict_test) print(df_test) df_filled = df_test.fillna('n') print(df_filled) - Output col1 col2 0 1.0 NaN 1 2.0 a 2 NaN b 3 4.0 NaN 4 NaN z col1 col2 0 1 n 1 2 a 2 n b 3 4 n 4 n z 위 예시를 보면 d..